|
|
XSL Attributes
|
An attributes can be accessed in the way similar to the elements. Notice @ in front of
the attribute name.
|
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>
|
|
You can do process the attribute in a same way as the element
|
You can also select the elements, which do contains or do not contains a given
attribute.
|
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,
|