title: XSL conversion from 2.0
body: <p>I have a problem converting XSLT 2.0 to XSLT 3.0. I want to use the streaming capability of XSLT 3.0. I am struggling with using the <code>&lt;xsl:stream&gt;</code> and <code>&lt;xsl:mode&gt;</code> tags as XSLT 3.0 has several restrictions. For using XSLT 3.0 streaming capabilities, following restrictions are faced:</p>
  
  <ol>
  <li>“Sibling nodes and ancestor sibling are not reachable”. </li>
  <li>"You can visit child nodes only once"</li>
  <li>"You have access only to the current element attributes and namespace declaration"</li>
  </ol>
  
  <p>How can I overcome these restrictions? Can anyone please help me?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"&gt;
  
           &lt;xsl:stream href="SampleInput3_0.xml"&gt;
              &lt;xsl:for-each select="copy-of(ns0:ORM_O01/ns0:ORM_O01.PATIENT/ns0:PID)"&gt;
                 &lt;Patient&gt;
                    &lt;ucfd:Name&gt;
                       &lt;xsl:variable name="varFirst_Name" as="node()" select="ns0:PID.5/ns0:XPN.2[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]" /&gt;
                       &lt;xsl:variable name="varLast_Name" as="node()" select="ns0:XPN.1/ns0:FN.1[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]" /&gt;
                       &lt;xsl:attribute name="value" namespace="" select="concat(string($varFirst_Name), string(varLast_Name))" /&gt;
                    &lt;/ucfd:Name&gt;
                    &lt;ucfd:FirstName value="{ns0:PID.5/ns0:XPN.2[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                    &lt;ucfd:LastName value="{ns0:PID.5/ns0:XPN.1/ns0:FN.1}" /&gt;
                    &lt;ucfd:MiddleName value="{ns0:PID.5/ns0:XPN.3[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                    &lt;ucfd:Prefix value="{ns0:PID.5/ns0:XPN.5[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                    &lt;ucfd:Suffix value="{ns0:PID.5/ns0:XPN.4[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                    &lt;ucfd:Identification&gt;
                       &lt;ucfd:TaxIdentifier&gt;
                          &lt;ucfd:Type value="{ns0:PID.18/ns0:CX.5[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                          &lt;ucfd:Identifier value="{ns0:PID.18/ns0:CX.1}" /&gt;
                       &lt;/ucfd:TaxIdentifier&gt;
                    &lt;/ucfd:Identification&gt;
                    &lt;xsl:for-each select="ns0:PID.11"&gt;
                       &lt;ucfd:Address&gt;
                          &lt;xsl:if test="exists(@Type)"&gt;
                             &lt;ucfd:Type value="{ns0:XAD.7[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                          &lt;/xsl:if&gt;
                          &lt;ucfd:City value="{ns0:XAD.3[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                          &lt;ucfd:State value="{ns0:XAD.4[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                          &lt;ucfd:PostalCode value="{ns0:XAD.5[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                          &lt;ucfd:Country value="{ns0:XAD.6[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                          &lt;ucfd:County value="{ns0:XAD.9[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                       &lt;/ucfd:Address&gt;
                    &lt;/xsl:for-each&gt;
                    &lt;ucfd:Contact&gt;
                       &lt;ucfd:Role value="{ns0:PID.13/ns0:XTN.2[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                       &lt;ucfd:Type value="{ns0:PID.13/ns0:XTN.3[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                       &lt;xsl:for-each select="ns0:PID.13"&gt;
                          &lt;!--&lt;xsl:variable name="var9_current" as="node()" select="."/&gt;--&gt;
                          &lt;ucfd:CommunicationNumber&gt;
                             &lt;xsl:if test="exists(@Type)"&gt;
                                &lt;ucfd:Type&gt;
                                   &lt;xsl:sequence select="()" /&gt;
                                &lt;/ucfd:Type&gt;
                             &lt;/xsl:if&gt;
                             &lt;ucfd:Identifier&gt;
                                &lt;!--&lt;xsl:variable name="var8_current" as="node()" select="ns0:XTN.5[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]"/&gt;
                                  &lt;xsl:variable name="var7_current" as="node()" select="ns0:XTN.6[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]"/&gt;
                                  &lt;xsl:variable name="var6_current" as="node()" select="ns0:XTN.7[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]"/&gt;
                                  &lt;xsl:variable name="var5_current" as="node()" select="ns0:XTN.8[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]"/&gt;
                                  &lt;xsl:variable name="var4_current" as="node()" select="ns0:XTN.10[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]"/&gt;
                                  &lt;xsl:variable name="var3_current" as="node()" select="ns0:XTN.11[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]"/&gt;
                                  &lt;xsl:attribute name="value" namespace="" select="concat(concat(concat(concat(concat(string($var8_current), string($var7_current)), string($var6_current)), string($var5_current)), string($var4_current)), string($var3_current))"/&gt; --&gt;
                             &lt;/ucfd:Identifier&gt;
                          &lt;/ucfd:CommunicationNumber&gt;
                       &lt;/xsl:for-each&gt;
                    &lt;/ucfd:Contact&gt;
                    &lt;ucfd:Demographics&gt;
                       &lt;ucfd:BirthDate&gt;
                          &lt;xsl:sequence select="()" /&gt;
                       &lt;/ucfd:BirthDate&gt;
                       &lt;ucfd:BirthSequenceNumber&gt;
                          &lt;xsl:for-each select="ns0:ORM_O01/ns0:ORM_O01.PATIENT/ns0:PID/ns0:PID.25"&gt;
                             &lt;xsl:attribute name="value" namespace=""&gt;
                                &lt;xsl:if test="not((translate(string(@xsi:nil), 'true ', '1') = '1'))"&gt;
                                   &lt;xsl:sequence select="xs:string(xs:integer(string(.)))" /&gt;
                                &lt;/xsl:if&gt;
                             &lt;/xsl:attribute&gt;
                          &lt;/xsl:for-each&gt;
                       &lt;/ucfd:BirthSequenceNumber&gt;
                       &lt;ucfd:DeathDate&gt;
                          &lt;xsl:sequence select="()" /&gt;
                       &lt;/ucfd:DeathDate&gt;
                       &lt;ucfd:Gender value="ns0:PID.8[not((translate(string(@xsi:nil), 'true ', '1') = '1'))]" /&gt;
                       &lt;ucfd:MaritalStatus value="{ns0:PID.16/ns0:CE_0002.1[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                       &lt;ucfd:CitizenshipStatus value="{ns0:PID.26[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                       &lt;ucfd:RaceOrEthnicity&gt;
                          &lt;ucfd:Race value="{ns0:PID.10/ns0:CE_0005.1[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                       &lt;/ucfd:RaceOrEthnicity&gt;
                       &lt;ucfd:Religion value="{ns0:PID.17/ns0:CE_0006.2[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                    &lt;/ucfd:Demographics&gt;
                    &lt;ucfd:Language&gt;
                       &lt;ucfd:LanguageCode value="{ns0:PID.15/ns0:CE_0296.1[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                       &lt;ucfd:Description value="{ns0:PID.15/ns0:CE_0296.2[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                       &lt;ucfd:UseIndicator value="{ns0:PID.15/ns0:CE_0296.3[not(translate(@xsi:nil, 'true ', '1') = '1')]}" /&gt;
                    &lt;/ucfd:Language&gt;
                 &lt;/Patient&gt;
              &lt;/xsl:for-each&gt;
           &lt;/xsl:stream&gt;
        &lt;/MemberRecord&gt;
     &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>