Extracting subset of XML using XSLT
Hi all,
Am trying to do a simple xml extraction using xslt.
The goal is to extract a simplified format of xml from a complex xml structure.
for e.g.
the sample XML is given below
<?xml version="1.0" encoding="UTF-8"?>
<eu>
<member name='arbitrary'>
<state>Austria</state>
<state founding="yes">Belgium</state>
<state>United Kingdom</state>
</member>
</eu>
the output required is
<?xml version="1.0" encoding="UTF-8"?>
<state>Austria</state>
<state founding="yes">Belgium</state>
<state>United Kingdom
</state>
The xslt used is
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="eu">
<xsl:apply-templates select="member"/>
</xsl:template>
<xsl:template match="member">
<xsl:apply-templates select="state"/>
</xsl:template>
<xsl:template match="state">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
When i use this particular xslt i get the correct value,
however the input xml has an attribute for the root node.
so the actual xml is
<eu version="2001" xmlns="http://europa.eu/ebiz" xmlns:ebiz="http://europa.eu/ebiz" xsi:schemaLocation="http://europa.eu/ebiz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<member name='arbitrary'>
<state>Austria</state>
<state founding="yes">Belgium</state>
<state>United Kingdom</state>
</member>
</eu>
the xslt when applied provides the following output
<?xml version="1.0" encoding="UTF-8"?>
Austria
Belgium
United Kingdom
This is not what I wanted, so am i missing something basic here ?
Can someone please let me know where iam getting this wrong ?
Thanks in advance
|