[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Qualified Attrib Value

Subject: RE: Qualified Attrib Value
From: "Steven Livingstone" <s.livingstone@xxxxxxxxxxxxxx>
Date: Tue, 20 Aug 2002 13:07:50 +0100
niko luojum ki
Thanks Jeni - 
That is exactly what I wanted to know.

Using MSXML 4.0 you can do this.. (where @att="myns:hello") to return
"hello"....

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <xsl:template match="contact">
     	<xsl:value-of select="msxsl:local-name(@att)" />
    </xsl:template>
</xsl:stylesheet>

I'm using .Net Xslt however and I don't think it supports the extension
functions :S
Steven.

-----Original Message-----
From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx] 
Sent: 20 August 2002 12:38
To: Steven Livingstone
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Qualified Attrib Value


Hi Steven,

> How do I get the value of the "test" attrib (contains a value 
> qualified in myprefix associated namespace) within this fragment 
> without the prefix? (not using string manipulation, but proper Xpath).
>
> <el test="myprefix:val" />

XSLT 1.0 doesn't support schemas, so an XSLT 1.0 processor doesn't know
that the test attribute contains a qualified name, from which it should
be able to extract a local part and a namespace URI. As far as the XSLT
1.0 processor is concerned, the test attribute contains a string. So if
you want to get information from that string then you
*have* to use string manipulation:

  substring-after(@test, ':')

When XPath 2.0 comes around, if you work with a processor that supports
W3C XML Schema and you have a schema that says that the test attribute
is of type xs:QName then the test attribute's "typed value" will be the
qualified name. You can get the typed value of a node with the data()
function. You can then extract the local part of the QName with the
get-local-name-from-QName() function, so use:

  get-local-name-from-QName(data(@test))

[Each time I think about using these get-property-from-dataType()
functions I want to scream.]

You'll still be able to use the former method in XPath 2.0, and that
gives you the benefit of not relying on someone using a W3C XML
Schema-aware XSLT processor (which I imagine will be rare beasts) nor on
the schema being available when you do the transformation (a risky
assumption in a networked environment), but the latter will deal
comfortably with the situation where the qualified name in the test
attribute doesn't have a prefix, whereas the string manipulation method
returns an empty string in that case.
 
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.