I have to transform an xml file using XSLT.
I had to get in the output the some structure of the input file file, expected some changes in some elements exsiting on a CDATA element.
<soapenv:Envelope xmlns:aa="http://example.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<aa:importOrder>
<aa:orderNumber>00501010000342</aa:orderNumber>
<aa:data>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<OrderImport xmlns="http://test.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema">
<OrderNumber>00501010000342</OrderNumber>
<Application>
<Student>
<DataElement>
<Name>age</Name>
<Type>Int</Type>
<Value>13</Value>
</DataElement>
<DataElement>
<Name>firstName</Name>
<Type>String</Type>
<Value>taha</Value>
</DataElement>
</Student>
</Application>
</OrderImport>
]]>
</aa:data>
</aa:importOrder>
</soapenv:Body>
</soapenv:Envelope>
My expected output should be like this:
<soapenv:Envelope xmlns:aa="http://example.com"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<aa:importOrder>
<aa:orderNumber>00501010000342</aa:orderNumber>
<aa:data>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<OrderImport xmlns="http://test.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema">
<OrderNumber>00501010000342</OrderNumber>
<Application>
<Student>
<DataElement>
<Name>age</Name>
<Type>Int</Type>
**<Value>Other Value</Value>**
</DataElement>
<DataElement>
<Name>firstName</Name>
<Type>String</Type>
**<Value>Other Value</Value>**
</DataElement>
</Student>
</Application>
</OrderImport>
]]>
</aa:data>
</aa:importOrder>
</soapenv:Body>
</soapenv:Envelope>
For that i used this xsl file:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="DataElement">
<p>
<xsl:apply-template select="name"/>
</p>
</xsl:template>
<xsl:template match="Name | Type">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="Value">
Other Value
</xsl:template>
but I didn't had the expected output.
Thanks in Advance
aa:data
element requires a second parsing step that is only possible with XSLT 3 andparse-xml
or with earlier versions and a processor dependent extension function. – Martin Honnen