Reputation: 2938
I have an XML such as:
<Response xmlns="www.google.com">
<Result>
<Errors xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>1sterror</a:string>
<a:string>another error</a:string>
</Errors>
</Result>
</Response>
I am trying an ouput something like as below:
<?xml version="1.0" encoding="UTF-8"?>
<pagedata xmlns:aa="www.google.com"
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<test>1sterror</test>
<test>another error</test>
</pagedata>
The XSL that i am making is:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:aa="www.google.com"
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<xsl:output method="xml" indent="yes" />
<xsl:template match="aa:Response">
<xsl:apply-templates select="aa:Result" />
</xsl:template>
<xsl:template match="aa:Result">
<pagedata>
<xsl:apply-templates select="aa:Errors"/>
</pagedata>
</xsl:template>
<xsl:template match="aa:Errors">
<xsl:apply-templates select="a:string"/>
</xsl:template>
<xsl:template match="a:string">
<test>
<xsl:value-of select="a:string"/>
</test>
</xsl:template>
</xsl:stylesheet>
But the output that I am getting is:
<?xml version="1.0" encoding="UTF-8"?>
<pagedata xmlns:aa="www.google.com"
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<test/>
<test/>
</pagedata>
This is coming without the data. Can anyone help ?
Upvotes: 0
Views: 29
Reputation: 6615
In your current XSLT, you are getting the value of an element a:string
within the a:string
element. If you want to get the value of the current node, use a .
change your XSLT into this:
<xsl:template match="a:string">
<test>
<xsl:value-of select="."/>
</test>
</xsl:template>
Upvotes: 1