Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

XSLT problem.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a XSLT code which works fine and it is as follows :
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="xml" indent="yes"/>

<xsl:template match="/">
<PERIODIC_TABLE><xsl:apply-templates/></PERIODIC_TABLE>
</xsl:template>
<xsl:template match="PERIODIC_TABLE/node()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="PERIODIC_TABLE/ATOM[NAME='Swarup']">
<xsl:element name="ATOM">
<xsl:copy-of select="@*"/>
<xsl:copy-of select="node()"/>

<xsl:element name="NAME">
<xsl:attribute name="b">x</xsl:attribute>Swap</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Now on the same lines if i use this code IT DOES NOT WORK as the DEPTH (i.e company/companyDetails/classificationInfo) increases it gives problem....
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="xml" indent="yes"/>

<xsl:template match="/">
<company><xsl:apply-templates/></company>
</xsl:template>
<xsl:template match="company/node()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="company/companyDetails/classificationInfo[naics='333412']">
<xsl:element name="classificationInfo">
<xsl:copy-of select="@*"/>
<xsl:copy-of select="node()"/>

<xsl:element name="naics">
<xsl:attribute name="naics">007</xsl:attribute>77777</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Thanks in Advance...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic