Home > OS >  Using the 'document' function in XSLT, how do you get the value from the contents of the r
Using the 'document' function in XSLT, how do you get the value from the contents of the r

Time:02-18

Right now I call an external webservice and store its response (XML) as a variable like this (using XSL 2.0):

<xsl:variable name="ReturnMICRFormatDocument">
   <xsl:value-of select="document($ReturnMICRFormatFullURL)"/>
</xsl:variable>

I then try to read values from specific elements of the returned document's XML:

<xsl:value-of select="$ReturnMICRFormatDocument/Bank/BankName"/>

... but it yields no value. Example of the returned XML:

<?xml version="1.0" encoding="utf-8"?>
<Bank xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <RoutingNumber xmlns="">121000248</RoutingNumber>
    <BankName xmlns="">WELLS FARGO BANK</BankName>
    <FormatMatches xmlns="">
        <FormatMatch MatchType="HARD" AccountLength="13">
            <CheckMICRFormat>@121000248@XCCCCCCCCCCCCC*XXXXX</CheckMICRFormat>
            <DepositMICRFormat>@518200392@XCCCCCCCCCCCCC*XXXXX</DepositMICRFormat>
        </FormatMatch>
    </FormatMatches>
</Bank>

Thanks for any assistance here!

CodePudding user response:

Simply use <xsl:variable name="doc2" select="document($url)"/> or, if you really want xsl:variable with a sequence constructor inside, use xsl:copy-of, not xsl:value-of.

  • Related