aspose file tools*
The moose likes XML and Related Technologies and the fly likes XSLT problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSLT problem." Watch "XSLT problem." New topic
Author

XSLT problem.

Swarup Sathe
Greenhorn

Joined: Aug 04, 2001
Posts: 6
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XSLT problem.
 
Similar Threads
xml to xml transform
XML Tranformation using XSLT
How to insert a structure into XML
to EXACT Dublicate an xml file[xml->xml] via Java TransformerFactory classes and XSTL well I do not
[XSLT] remove a particular node