P
Pathik
Hi All,
Currently I am trying to convert one xml file into another xml file
which having different format than original xml file.
my input xml file is like:
<?xml version="1.0" encoding="UTF-8"?>
<MyData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:n1="http://www.abc.com/resources/XML/schemas/v2_0">
<header>
<id>1</id>
<test>xyz</test>
</header>
<n1ataSet>
<n1:Group REF="SE" ADJ="N"
ABC_I="PROD" ABC_A="N100C0" ABC_IN="1"
ABC_B_Y="2000"/>
<n1:Series FR="M" REF="SE" ADJ="N"
ABC_I="PROD" ABC_A="N100C0" ABC_IN="1"
ABC_B_Y="2000">
<n1:Obs TIME_P="199001" OBS_VALUE="101.2"/>
<n1:Obs TIME_P="199002" OBS_VALUE="103.2"/>
<n1:Obs TIME_P="199003" OBS_VALUE="105.2"/>
<n1:Obs TIME_P="199004" OBS_VALUE="107.2"/>
</n1:Series>
</n1ataSet>
</MyData>
I have to extract the Series element based on the values of ADJ,ABC_A
etc.My intend is more clear from the following xsl file:
The problem is that in xpath expression it doesn't recognizing
namespace elements ie elements prefixed with n1
Please check this and let me know where i am doing wrong.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:n1="http://www.abc.com/resources/XML/schemas/v2_0">
<xslutput method="xml" encoding="UTF-8" indent="yes"/>
<xslaram name="REF"/>
<xslaram name="ADJ"/>
<xslaram name="ABC_I"/>
<xslaram name="ABC_A"/>
<xslaram name="ABC_IN"/>
<xslaram name="ABC_B_Y"/>
<xsl:template match="/">
<Data>
<Table language="en">
<Info>
</Info>
<Nomenclatures>
</Nomenclatures>
<Context>
<Selector type="theme" code="theme1"/>
<Selector type="domain" code="euro"/>
<Selector type="table" code="bp_q"/>
</Context>
<Grid>
<AxisZ name="REF">
<xsl:for-each
select="MyData/n1ataSet/n1:Series[
@ADJ=$ADJ and
@ABC_A=$ABC_A and
@ABC_IN=$ABC_I and
@ABC_B_Y=$ABC_B_Y]">
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:value-of select="@REF"/>
</xsl:attribute>
</xsl:element>
<AxisY name="STS_INDICATOR">
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:value-of select="@ABC_IN"/>
</xsl:attribute>
</xsl:element>
<AxisX name="time">
<xsl:for-each select="./n1:Obs">
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:value-of
select="@TIME_P"/>
</xsl:attribute>
</xsl:element>
<xsl:element name="Cell">
<xsl:attribute name="value">
<xsl:value-of
select="@OBS_VALUE"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</AxisX>
</AxisY>
</xsl:for-each>
</AxisZ>
</Grid>
</Table>
</Data>
</xsl:template>
</xsl:stylesheet>
Thanks and Regards,
Pathik
Currently I am trying to convert one xml file into another xml file
which having different format than original xml file.
my input xml file is like:
<?xml version="1.0" encoding="UTF-8"?>
<MyData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:n1="http://www.abc.com/resources/XML/schemas/v2_0">
<header>
<id>1</id>
<test>xyz</test>
</header>
<n1ataSet>
<n1:Group REF="SE" ADJ="N"
ABC_I="PROD" ABC_A="N100C0" ABC_IN="1"
ABC_B_Y="2000"/>
<n1:Series FR="M" REF="SE" ADJ="N"
ABC_I="PROD" ABC_A="N100C0" ABC_IN="1"
ABC_B_Y="2000">
<n1:Obs TIME_P="199001" OBS_VALUE="101.2"/>
<n1:Obs TIME_P="199002" OBS_VALUE="103.2"/>
<n1:Obs TIME_P="199003" OBS_VALUE="105.2"/>
<n1:Obs TIME_P="199004" OBS_VALUE="107.2"/>
</n1:Series>
</n1ataSet>
</MyData>
I have to extract the Series element based on the values of ADJ,ABC_A
etc.My intend is more clear from the following xsl file:
The problem is that in xpath expression it doesn't recognizing
namespace elements ie elements prefixed with n1
Please check this and let me know where i am doing wrong.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:n1="http://www.abc.com/resources/XML/schemas/v2_0">
<xslutput method="xml" encoding="UTF-8" indent="yes"/>
<xslaram name="REF"/>
<xslaram name="ADJ"/>
<xslaram name="ABC_I"/>
<xslaram name="ABC_A"/>
<xslaram name="ABC_IN"/>
<xslaram name="ABC_B_Y"/>
<xsl:template match="/">
<Data>
<Table language="en">
<Info>
</Info>
<Nomenclatures>
</Nomenclatures>
<Context>
<Selector type="theme" code="theme1"/>
<Selector type="domain" code="euro"/>
<Selector type="table" code="bp_q"/>
</Context>
<Grid>
<AxisZ name="REF">
<xsl:for-each
select="MyData/n1ataSet/n1:Series[
@ADJ=$ADJ and
@ABC_A=$ABC_A and
@ABC_IN=$ABC_I and
@ABC_B_Y=$ABC_B_Y]">
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:value-of select="@REF"/>
</xsl:attribute>
</xsl:element>
<AxisY name="STS_INDICATOR">
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:value-of select="@ABC_IN"/>
</xsl:attribute>
</xsl:element>
<AxisX name="time">
<xsl:for-each select="./n1:Obs">
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:value-of
select="@TIME_P"/>
</xsl:attribute>
</xsl:element>
<xsl:element name="Cell">
<xsl:attribute name="value">
<xsl:value-of
select="@OBS_VALUE"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</AxisX>
</AxisY>
</xsl:for-each>
</AxisZ>
</Grid>
</Table>
</Data>
</xsl:template>
</xsl:stylesheet>
Thanks and Regards,
Pathik