Subject: RE: [xsl] Qualified Attrib Value From: "Steven Livingstone" <s.livingstone@xxxxxxxxxxxxxx> Date: Tue, 20 Aug 2002 13:07:50 +0100 |
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: [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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Qualified Attrib Value, Jeni Tennison | Thread | RE: [xsl] Qualified Attrib Value, Jarno . Elovirta |
[xsl] XSL-parsing problem, Niko Luojumäki | Date | Re: [xsl] XSL-parsing problem, Jeni Tennison |
Month |