Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: value-of select=...[@attribute]

From: "Neil Smith [MVP Digital Media]" <neil@------.--->
To: NULL
Date: 7/8/2006 5:29:00 PM

On Sat, 08 Jul 2006 18:52:58 +0200, Tobias Krause <spamtk@w...>
wrote:

>Hi,
>
>I got a XML file like [3] and I'd need to get the value of the type
>attribute.
>Why does [1] return the number it self while [2] returns the value of
>the type attribute?


It's doing exactly what you told it : 

<xsl:value-of select="phonenumbers/number[@type]"/> selects the text
content of the number node, as long as it has an attribute of "type".

<xsl:value-of select="@type"/> selects the value of the attribute
called `type` in your XML.


>Is there a way to get the value of the type attribute in the
>match="entry" example?


Yes, you want to use 
<xsl:value-of select="phonenumbers/number/@type"/>

Followed swiftly by a basic XPath tutorial refresher - can I suggest
http://www.w3schools.com/xpath/xpath_syntax.asp

HTH
Cheers - Neil

>Regards, Toby
>
>[1]
><xsl:template match="entry">
>    <xsl:value-of select="phonenumbers/number[@type]"/>
></xsl:template>
>
>
>[2]
><xsl:template match="number">
>    <xsl:value-of select="@type"/>
></xsl:template>
>
>
>[3]
><entry private="false">
>	<phonenumbers standard="mobile">
>		<number type="mobile">+49176***/number>
>	</phonenumbers>
></entry>
------------------------------------------------
Digital Media MVP : 2004-2006
http://mvp.support.microsoft.com/mvpfaqs


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent