This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Qualified Attrib Value


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@jenitennison.com] 
Sent: 20 August 2002 12:38
To: Steven Livingstone
Cc: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]