1 Reply Latest reply on May 18, 2017 6:39 AM by BjornEricsson

    Problem inserting XML variable in XSLT Source template

    BjornEricsson Level 1

      I can't figure out how to inserting process variables of type XML into XSLT Source templates. I have no problem inserting variables of type String.


      This is the insert part of my stylesheet:


       <xsl:variable name="stringvariable" select="'{$/process_data/@stringVariable$}'"/>
       <xsl:variable name="externalNodes" select="'{$/process_data/inputNodeNames$}'"/>


      The string variable is inserted and later printed for verification.


      I have also created a local variable (with same contents as external) for reference:


       <xsl:variable name="internalNodes">
        <root xmlns:fo="http://www.w3.org/1999/XSL/Format">
         <block>$.Formularmetadata</block>
         <block>$.Sorteringsdata</block>
         <block>$.Metadata</block>
         <block>$.Verksamhetsdata</block>
        </root>
       </xsl:variable>


      I then invoke count(exsl:node-set()) on both variable in the template, but only the local have a value over 0.


      How can I get this to work?


      /BS


      PS. This is the full XSL stylesheet:


      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl">
       <xsl:output omit-xml-declaration="yes" indent="yes"/>
       
       <xsl:variable name="stringvariable" select="'{$/process_data/@stringVariable$}'"/>
       <xsl:variable name="externalNodes" select="'{$/process_data/inputNodeNames$}'"/>
       <xsl:variable name="internalNodes">
        <root xmlns:fo="http://www.w3.org/1999/XSL/Format">
         <block>$.Formularmetadata</block>
         <block>$.Sorteringsdata</block>
         <block>$.Metadata</block>
         <block>$.Verksamhetsdata</block>
        </root>
       </xsl:variable>
       
       <!-- Identity rule.-->
       <xsl:template match="node()|@*">
        <xsl:copy>
         <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
       </xsl:template>
       
       <!-- Rewrite attribute ref to work with new XML.-->
       <xsl:template match="*[local-name()='bind']/@ref">
        <xsl:value-of select="$stringvariable "/>
        <xsl:value-of select="' Internal'"/><xsl:value-of select="count(exsl:node-set($internalNodes)/root/block)"/>
        <xsl:value-of select="' External'"/><xsl:value-of select="count(exsl:node-set($externalNodes)/root/block)"/>
       </xsl:template>
      </xsl:stylesheet>