[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|