|
|
XSL Attributes
|
Gli attributi possono essere raggiunti nel senso simile agli elementi. Avviso @ davanti il nome di attributo.
|
XML source
<?xml version="1.0"?>
<xslTutorial >
<dog name='Joe'>
<data weight='18 kg' color="black"/>
</dog>
</xslTutorial>
|
HTML output 1
<HTML>
<HEAD> </HEAD>
<BODY>
<P>
<B>Dog: </B>Joe</P>
<P>
<B>Color: </B>black</P>
</BODY>
</HTML>
|
|
XSL stylesheet 1
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="dog">
<P><B><xsl:text> Dog: </xsl:text> </B>
<xsl:value-of select="@name"/></P>
<P><B><xsl:text> Color: </xsl:text> </B>
<xsl:value-of select="data/@color"/></P>
</xsl:template>
</xsl:stylesheet>
|
|
Potete fare il processo l'attributo in uno stesso senso dell'elemento
|
Potete anche selezionare gli elementi, che contengono o non contengono un dato attributo.
|
XML source
<?xml version="1.0"?>
<xslTutorial >
<car id='a234' checked='yes' />
<car id='a111' checked='yes' />
<car id='a005' />
</xslTutorial>
|
HTML output 1
<HTML>
<HEAD> </HEAD>
<BODY>
<P>Car: a234</P>
<P>Car: a111</P>
</BODY>
</HTML>
|
HTML output 2
<HTML>
<HEAD> </HEAD>
<BODY>
<P>Car: a005</P>
</BODY>
</HTML>
|
|
XSL stylesheet 1
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="car[@checked]">
<P><xsl:text> Car: </xsl:text>
<xsl:value-of select="@id"/></P>
</xsl:template>
</xsl:stylesheet>
|
XSL stylesheet 2
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:template match="car[not(@checked)]">
<P><xsl:text> Car: </xsl:text>
<xsl:value-of select="@id"/></P>
</xsl:template>
</xsl:stylesheet>
|
|
|
|
Keywords XSL Attributes, xpath attributes, xsd attributes, xslt attributes, xsl for each,
stylesheet attributes, xsl value of, attributes xsl, xsl copy attributes, asp net xsl,
attributes in xsl, asp net attributes, xml attributes, display xsl, text attributes,
display attributes, value xsl, parse attributes, attributes examples, xsl using,
xsl generate, using attributes, convert xsl, xml attribute, xsl multiple, tag attributes,
xsl attribute, xslt attribute,
|