How to break XSLT for-each loop -


this xml structure want parse value using each in run time

 <header> 'xml structure start here'         <docnumber>743439</docnumber> 'document number'            <order>           <order>450</order> '1 st order number'           <orderdetails>              <itemcode>1232954</itemcode>             <qty> 'quantity;               72             </qty>               </orderdetails>          <orderdetails>              <itemcode>1232955</itemcode>             <qty>               72             </qty>              </orderdetails>     </order>     <order>           <order>451</order> 'second order number'           <orderdetails>              <itemcode>1232954</itemcode>             <qty>               72             </qty>             </orderdetails>          <orderdetails>              <itemcode>1232955</itemcode>             <qty> 'quantity'               72             </qty>                           </orderdetails>     </order> 'xml structure finished here' 

my xslt:

  <xsl:for-each select="header/order">      <xsl:variable name="orderno" select="order"/>      <xsl:for-each select="header/order[order='450']/orderdetails"> 'here order number want pass in variable value. how .it's not fixed next time it's change 451.'     </xsl:foreach>  </xsl:foreach> 

in each loop want pass order number using variable. how .it's not fixed next time it's change 451. tried using variable <xsl:for-each select="header/order[order=<xsl:value-of select="$orderno"/> ]/orderdetails">. it's not working

it looks each order element selecting, want iterate on child orderdetail elements.

you don't need complicated this, nested xsl:for-each can contain xpath expression relative current node.

 <xsl:for-each select="header/order">      order - <xsl:value-of select="order" />      <xsl:for-each select="orderdetails">         itemcode - <xsl:value-of select="itemcode" />     </xsl:for-each>  </xsl:for-each> 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -