cheap nfl jerseys china cheap nfl jerseys free shipping wholesale nfl jerseys china wholesale jerseys from china cheap nfl jerseys free shipping cheap nfl jerseys for sale cheap jerseys free shipping wholesale nfl jerseys from china cheap nfl jerseys sale cheap nike nfl jerseys china wholesale jerseys free shipping cheap nfl jerseys wholesale wholesale nfl jerseys online cheap nfl jerseys wholesale china jerseys wholesale cheap coach handbags outlet authentic designer handbags cheap coach handbags outlet cheap coach purses outlet discount coach bags coach bags sale coach purse outlet cheap real coach purses coach handbags sale online coach purse outlet michael kors outlet online store cheap michael kors bags cheap michael kors purse michael kors factory outlet online cheap michael kors handbags cheap michael kors purses michael kors bags outlet online cheap michael kors purse michael kors handbags discount cheap michael kors purse michael kors handbags discount
cheap nfl jerseys china cheap nfl jerseys free shipping wholesale nfl jerseys china wholesale jerseys from china cheap nfl jerseys free shipping cheap nfl jerseys for sale cheap jerseys free shipping wholesale nfl jerseys from china cheap nfl jerseys sale cheap nike nfl jerseys china wholesale jerseys free shipping cheap nfl jerseys wholesale wholesale nfl jerseys online cheap nfl jerseys wholesale china jerseys wholesale cheap coach handbags outlet authentic designer handbags cheap coach handbags outlet cheap coach purses outlet discount coach bags coach bags sale coach purse outlet cheap real coach purses coach handbags sale online coach purse outlet michael kors outlet online store cheap michael kors bags cheap michael kors purse michael kors factory outlet online cheap michael kors handbags cheap michael kors purses michael kors bags outlet online cheap michael kors purse michael kors handbags discount cheap michael kors purse michael kors handbags discount
>> pag. 66 << | indietro | avanti | indice | indice analitico

66.

La funzione generate-id genera id conformi alle specifiche XML. Questo stylesheet usa questa funzione per aggiungere id a tutti gli elementi del sorgente XML.

XSLT stylesheet 1

XML Source
<source>

<AAA name="top">
     <BBB pos="1" val="bbb">11111</BBB>
     <BBB>22222</BBB>
</AAA>
<AAA name="bottom">
     <BBB>33333</BBB>
     <BBB>44444</BBB>
</AAA>

</source>

Output
<DIV>
  <B>generate-id(//AAA) : </B>d0e3</DIV>
<DIV>
  <B>generate-id(//BBB) : </B>d0e5</DIV>
<DIV>
  <B>generate-id(//AAA[1]) : </B>d0e3</DIV>
<DIV>
  <B>generate-id(//*[1]) : </B>d0e1</DIV>
<DIV>
  <B>generate-id(//xslTutorial/*[1]) : </B>
</DIV>

HTML view
generate-id(//AAA) : d0e3
generate-id(//BBB) : d0e5
generate-id(//AAA[1]) : d0e3
generate-id(//*[1]) : d0e1
generate-id(//xslTutorial/*[1]) :
XSLT stylesheet
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="/">
     <DIV>
          <B>
               <xsl:text>generate-id(//AAA) : </xsl:text>
          </B>
          <xsl:value-of select="generate-id(//AAA) "/>
     </DIV>
     <DIV>
          <B>
               <xsl:text>generate-id(//BBB) : </xsl:text>
          </B>
          <xsl:value-of select="generate-id(//BBB) "/>
     </DIV>
     <DIV>
          <B>
               <xsl:text>generate-id(//AAA[1]) : </xsl:text>
          </B>
          <xsl:value-of select="generate-id(//AAA[1]) "/>
     </DIV>
     <DIV>
          <B>
               <xsl:text>generate-id(//*[1]) : </xsl:text>
          </B>
          <xsl:value-of select="generate-id(//*[1]) "/>
     </DIV>
     <DIV>
          <B>
               <xsl:text>generate-id(//xslTutorial/*[1]) : </xsl:text>
          </B>
          <xsl:value-of select="generate-id(//xslTutorial/*[1]) "/>
     </DIV>
</xsl:template>


</xsl:stylesheet>



XSLT stylesheet 2

XML Source
<source>

<AAA name="top">
     <BBB pos="1" val="bbb">11111</BBB>
     <BBB>22222</BBB>
</AAA>
<AAA name="bottom">
     <BBB>33333</BBB>
     <BBB>44444</BBB>
</AAA>

</source>

Output
<source id="d0e1">

  <AAA id="d0e3" name="top">

     <BBB id="d0e5" pos="1" val="bbb">11111</BBB>

     <BBB id="d0e8">22222</BBB>

  </AAA>

  <AAA id="d0e12" name="bottom">

     <BBB id="d0e14">33333</BBB>

     <BBB id="d0e17">44444</BBB>

  </AAA>

</source>

HTML view
11111 22222 33333 44444
XSLT stylesheet
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="*">
     <xsl:copy>
          <xsl:attribute name="id">
               <xsl:value-of select="generate-id()"/>
          </xsl:attribute>
          <xsl:for-each select="@*">
               <xsl:attribute name="{name()}">
                    <xsl:value-of select="."/>
               </xsl:attribute>
          </xsl:for-each>
          <xsl:apply-templates/>
     </xsl:copy>
</xsl:template>


</xsl:stylesheet>