Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] XPath expression to return an attribute's value

From: "Michael Kay" <mike@--------.--->
To: "'Rachel D. Basse'" <honestrosewater@-----.--->,<xml-dev@-----.---.--->
Date: 3/5/2007 12:40:00 AM
string(Root/@Attribute) returns the string-value

data(Root/@Attribute) returns the typed value

In most contexts where you want the typed value, the data() function is
applied automatically (a process called atomization) so you rarely see it
written explicitly. For example

Root/@Attribute = 'Value'

would return true, since the "=" operator automatically atomizes its
operands.

You don't say what is the type of the attribute - in your example it looks
like a string, in which case the string value and the typed value are
effectively the same thing.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Rachel D. Basse [mailto:honestrosewater@c...] 
> Sent: 04 March 2007 09:44
> To: xml-dev@l...
> Subject: [xml-dev] XPath expression to return an attribute's value
> 
> Greetings. :^)
> 
> This question came up while using XSLT 2.0 and XPath 2.0. I'd 
> like to root out any related, more general misunderstandings 
> if possible.
> 
> Given
> 
>  <Root Attribute="Value"/>
> 
> I want to make an XPath path expression evaluate to the 
> string "Value". So I want the XDM typed-value of the 
> Attribute attribute, yes? Does XPath have a way to refer to 
> the typed-valued of an attribute?
> 
> My first instinct was to refer to the child text node of 
> Attribute, using "Attribute/text()", but that won't work 
> since attributes have no children.
> 
> As I understand things, adding any predicate to an 
> "Attribute" path expression won't work since the expression 
> would still return an attribute node or nothing, and I want a 
> string, neither an attribute node nor nothing.
> 
> I can apparently get what I want by casting the attribute 
> node as a string, but I am wondering if there is another, 
> more direct way.
> 
> Thanks for reading,
> Rachel Basse
> 
> P.S. I am aware that I can also use xsl:value-of, but I 
> specifically want an XPath expression to evaluate to an 
> attribute's value.
> 
> 
> Care2 make the world greener!
> 
> Stop the Forest Service from killing more wolves, bears, 
> cougars, and other animals in the wild:
> http://go.care2.com/99055
> 
> http://www.Care2.com  Free e-mail. 100MB storage.  Helps nonprofits. 
> 
> ______________________________________________________________
> _________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by 
> OASIS to support XML implementation and development. To 
> minimize spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@l...
> subscribe: xml-dev-subscribe@l... List archive: 
> http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>


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