I'm trying to perform a 2 step transformation in my JSP file. I have a XML
structure for a document where all links are under <document_links>, the XML
also contains <paragraph> nodes.
I want to transform this XML document so that all nodes except <paragraph>
nodes are in the transformed XML.
I want to test if transforming from one XML structure to another was done
correctly before using the output of the transformation.
But there doesn't seem to be a way in JSLT to see the xml node structure. I
tried printing it with <x:out but it only outputs the text values and not the
xml nodes themselves.
I also tried to see the output of the transformation by performing clien-side
transformation with IE6.0, but this transformation also shows only the text
nodes.
How can I see the *transformed XML structure* ?
For example:
I want to transform the following XML structure
document.xml
<?xml version="1.0" encoding="UTF-8"?>
<document>
<!--
Commented out , used for IE6.0 transformation.
<?xml-stylesheet type="text/xsl" href="get_links.xsl"?>
-->
<document_links>
<link>
<id>1234</id>
<url><![CDATA[http://www.test.com]]></url>
</link>
</document_links>
<paragraph>
<![CDATA[
test text
]]>
</paragraph>
</document>
to this structure: (just trying to extract the XML with the link nodes,
excluding paragraph nodes)
<?xml version="1.0" encoding="UTF-8"?>
<document>
<!--
Commented out , used for IE6.0 transformation.
<?xml-stylesheet type="text/xsl" href="get_links.xsl"?>
-->
<document_links>
<link>
<id>1234</id>
<url><![CDATA[http://www.test.com]]></url>
</link>
</document_links>
</document>
This is the XSL:
get_links.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no" indent="no"/>
<xsl:template match="/">
<xsl:apply-templates select="document"/>
</xsl
nt">
<document>
<xsl:apply-templates select="document_links"/>
</document>
</xsl:template>
<xsl:template match="document_links">
<document-links>
<xsl:copy-of select="."/>
</document-links>
</xsl:template>
</xsl:stylesheet>
Snippet from JSP:
<c:import url="/document.xml" var="xml"/>
<c:import url="/get_links.xsl" var="xsl"/>
<x:transform xml="${xml}" xslt="${xsl}" var="links_xml"/>
<x:out select="$links_xml"/>
The above <x:out only shows 1234 http://www.test.com and not the XML structure.
I'm not sure if this is the right way to test the output of XML transformation
Any help is appreciated.
Regards
Rashmi
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--