You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Benoit Fouche <b....@cross-systems.com> on 2000/03/31 11:57:07 UTC
How to access xml tag attribute with XSL ?
Hi,
I'm novice with XSL, and I'd like to know if it's posible to access to an
XML tag attribute using an XSL stylesheet associated with the XML doc ?
example:
xml doc:
<card id='menuCard' title='menu1'>
<p align='left'>
Hello guys !
</p>
</card>
So, I would like to access to the "id" and "title" attributes of the tag
<card>...
I've writing this for the XSL stylesheet:
<?xml version="1.0" encoding="ISO8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<HTML>
<BODY>
<xsl:for-each select="wml/card">
...here i want to write the title of card...
<p align="center">
<xsl:apply-templates/>
</p>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Thank for helping me !
Ben.
bfouche@caramail.com
Re: How to access xml tag attribute with XSL ?
Posted by John Carroll <jc...@micromuse.com>.
Benoit Fouche wrote:
> Xsuse me John, but I think you do not understand my query...
> I'd like to access the attribut IN the XML DOCUMENT, and set it with the XSL
> stylesheet.
> (like the <xsl:value-of select='card'> but not the content of the tag
> <card>, just the attribut "id" that is in <card id='menuCard'>...
> So how can I recover this "id" attribut in the XML source ?
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail: webmaster@xml.apache.org
> To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
<xsl:value-of select="@title"/> for value of the title attribute
or
<xsl:value-of select="@id"/> for value of the id attribute
cheers,
John.
Re: How to access xml tag attribute with XSL ?
Posted by Benoit Fouche <b....@cross-systems.com>.
Xsuse me John, but I think you do not understand my query...
I'd like to access the attribut IN the XML DOCUMENT, and set it with the XSL
stylesheet.
(like the <xsl:value-of select='card'> but not the content of the tag
<card>, just the attribut "id" that is in <card id='menuCard'>...
So how can I recover this "id" attribut in the XML source ?
Re: How to access xml tag attribute with XSL ?
Posted by John Carroll <jc...@micromuse.com>.
Benoit Fouche wrote:
> Hi,
> I'm novice with XSL, and I'd like to know if it's posible to access to an
> XML tag attribute using an XSL stylesheet associated with the XML doc ?
>
> example:
> xml doc:
> <card id='menuCard' title='menu1'>
> <p align='left'>
> Hello guys !
> </p>
> </card>
>
> So, I would like to access to the "id" and "title" attributes of the tag
> <card>...
>
> I've writing this for the XSL stylesheet:
> <?xml version="1.0" encoding="ISO8859-1"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
>
> <xsl:template match="/">
> <HTML>
> <BODY>
> <xsl:for-each select="wml/card">
> ...here i want to write the title of card...
>
> <p align="center">
> <xsl:apply-templates/>
> </p>
> </xsl:for-each>
> </BODY>
> </HTML>
> </xsl:template>
>
> </xsl:stylesheet>
>
> Thank for helping me !
> Ben.
> bfouche@caramail.com
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail: webmaster@xml.apache.org
> To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
HI,
use
> <?xml version="1.0" encoding="ISO8859-1"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
>
> <xsl:template match="/">
> <HTML>
> <BODY>
> <xsl:for-each select="wml/card">
> ...here i want to write the title of card...
<xsl:value-of select="@title"/>
>
> <p align="center">
> <xsl:apply-templates/>
> </p>
> </xsl:for-each>
> </BODY>
> </HTML>
> </xsl:template>
cheers,
John.