Fonctions additionnelles diverses |
|
|
La fonction courante
|
� Une fonction courante � des retours noeud-a plac� qui a le noeud courant en tant que seul membre. Pour l'expression ext�rieure, l'expression qui ne se produit pas dans une autre expression, noeud courant est toujours m�me qu'un noeud de contexte. Cependant, dans les crochets le noeud courant est habituellement diff�rent du noeud de contexte.
|
XML source
<?xml version="1.0"?>
<xslTutorial >
<AAA name="first">
<BBB name="first">11111</BBB>
<BBB name="second">22222</BBB>
</AAA>
<AAA name="second">
<BBB name="first">33333</BBB> ;
<BBB name="second">44444</BBB>
</AAA>
</xslTutorial>
|
HTML output 1
<TABLE border="1">
<TR>
<TH> . </TH>
<TH>current()</TH></TR>
<TR>
<TD>first</TD>
<TD>first</TD></TR>
<TR>
<TD>11111</TD>
<TD>1111122222</TD></TR>
<TR>
<TD>second</TD>
<TD>second</TD></TR>
<TR>
<TD>33333</TD>
<TD/></TR></TABLE>
|
|
XSL stylesheet 1
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<TABLE border="1">
<TR><TH> . </TH><TH>current()</TH></TR>
<xsl:apply-templates select="//AAA"/>
</TABLE>
</xsl:template>
<xsl:template match="AAA">
<TR>
<TD>
<xsl:value-of select="./@name"/>
</TD><TD>
<xsl:value-of select="current()/@name"/>
</TD></TR>
<TR><TD>
<xsl:apply-templates select="BBB[./@name='first']"/>
</TD><TD>
<xsl:apply-templates select="BBB[current()/@name='first']"/>
</TD></TR>
</xsl:template>
</xsl:stylesheet>
|
|
Produire de l'identification
|
La produire-identification de fonction produit de l'identification conform�ment au XML Spec. Le Stylesheet 2 des utilisations la fonction produire-identification d'ajouter l'identification � tous �l�ments dans la source XML.
|
XML source
<?xml version="1.0"?>
<xslTutorial >
<AAA name='top'>
<BBB pos='1' val='bbb'>11111</BBB>
<BBB>22222</BBB>
</AAA>
<AAA name='bottom'>
<BBB>33333</BBB>
<BBB>44444</BBB>
</AAA>
</xslTutorial>
|
HTML output 1
<DIV>
<B>generate-id(//AAA) : </B>N3</DIV>
<DIV>
<B>generate-id(//BBB) : </B>N6</DIV>
<DIV>
<B>generate-id(//AAA[1]) : </B>N3</DIV>
<DIV>
<B>generate-id(//*[1]) : </B>N1</DIV>
<DIV>
<B>generate-id(//xslTutorial/*[1]) : </B>N3</DIV> |
|
XSL stylesheet 1
<xsl:stylesheet 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>
|
|
XML source
<?xml version="1.0"?>
<xslTutorial >
<AAA name='top'>
<BBB pos='1' val='bbb'>11111</BBB>
<BBB>22222</BBB>
</AAA>
<AAA name='bottom'>
<BBB>33333</BBB>
<BBB>44444</BBB>
</AAA>
</xslTutorial>
|
HTML output 2
<xslTutorial id="N1">
<AAA id="N3" name="top">
<BBB id="N6" pos="1" val="bbb">11111</BBB>
<BBB id="N11">22222</BBB> </AAA>
<AAA id="N15" name="bottom">
<BBB id="N18">33333</BBB>
<BBB id="N21">44444</BBB> </AAA> </xslTutorial>
|
|
XSL stylesheet 2
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="*">
<xsl:copy select=".">
<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>
|
|
|
|
Keywords Miscellaneous Additional Functions, XSL Functions, xsl string functions, xsl date functions,
xpath functions, xslt function, xsl function, xslt functions, xpath function, xslt string functions,
xpath string functions, xslt document function, xpath 1.0 functions, xsl document function,
xsl string function, functions in xsl, xpath 2.0 functions, xsl replace function,
xpath contains function, xpath count function, xslt date functions, xslt date function,
xslt replace function, xslt string function, functions in xslt, xsl date function, xsl count function
|