[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl][xslt v1.0] How to parse the string as node-set?


Subject: [xsl][xslt v1.0] How to parse the string as node-set?
From: Mak Praveen <praveenml@xxxxxxxxx>
Date: Fri, 28 Sep 2012 16:19:35 -0400

Hi All,

I am surprised that nowhere in the internet I could find a straight
forward solution to this.
I am trying to read an XML present inside an XML tag.

The below example would explain it.
May be I am missing something important here please help.

******** My Simplified XML ***********************

<?xml version="1.0" encoding="UTF-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
            <soap:Body>
                        <TransmitXML xmlns="http://xmlexchangeservice.com/">
                                    <InputXML>&lt;?xml version="1.0"
encoding="utf-8"?&gt;
                &lt;tns:CoverageRequest
xmlns:X12.7="urn:x12:schemas:V00200806:X12.7"
xmlns:tns="urn:schemas:x12:org:V00200806:CoverageRequest"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
PublicationVersion="00200809" PublicationDate="1984-02-12"&gt;
                    &lt;tns:RequestorInformation&gt;
                        &lt;tns:Organization&gt;
                            &lt;tns:Name&gt;Florida&lt;/tns:Name&gt;
                        &lt;/tns:Organization&gt;
                        &lt;tns:ReasonDetails&gt;
                            &lt;tns:ReasonCode&gt;ACCV&lt;/tns:ReasonCode&gt;
                        &lt;/tns:ReasonDetails&gt;
                    &lt;/tns:RequestorInformation&gt;
                &lt;/tns:CoverageRequest&gt;
        </InputXML>
        <XMLSchemaVersion>V00200806-ServiceRequest</XMLSchemaVersion>
</TransmitXML>
</soap:Body>
</soap:Envelope>

******** My XSLT  ***********************

I am trying to read the XML as node-set present inside InputXML

<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:al="http://xmlexchangeservice.com/"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
omit-xml-declaration="no"/>
<xsl:template match="/">
<xsl:variable  name="nodeval" >
      <xsl:value-of
select="soap:Envelope/soap:Body/al:TransmitXML/al:InputXML"
disable-output-escaping="yes"  />
</xsl:variable>
<xsl:element name="Testing">
<xsl:value-of
select="exsl:node-set($nodeval)/tns:CoverageRequest/tns:RequestorInformation/
tns:Organization/tns:Name"
/>
<!-- What I really want is to parse the XML inside the InputXML" like
some where below
 <xsl:apply-templates
select="exsl:node-set($nodeval)/tns:CoverageRequest"/>   -->
</xsl:element>
</xsl:template>
</xsl:stylesheet>


******************** The output should be **************************

<?xml version="1.0" encoding="UTF-8"?>
< Testing>
Florida
</Testing>


How do parse the XML within the InputXML tag? Thats my real question

-Thanks
PMak


Current Thread
Keywords