[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Generate key with further restriction
> How can I generate keys with certain restrictions? > Would something like that > <xsl:key name="usedTypes" match="@*[name() = 'type' and > not(starts-with(name(),'xs:'))]" use="." /> > work to select those attributes with the name type that do not start > with xs: ? If name() = 'type' then it is impossible that starts-with(name(),'xs:') Therefore: name() = 'type' and not(starts-with(name(),'xs:')) is equivalent to the shorter and more understandable: name() = 'type' Probably you wanted to use the function local-name() instead of name() But then the same namespace-uri may be associated to another prefix, let's say "ys", and the above (corrected) predicate will be true for that attribute node. Therefore, the correct way to ensure that a particular name does not belong to a given namespace is to use the namespace-uri of the namespace: Use: local-name() = 'type' and not(namespace-uri() = 'someNamespaceURI') Or, if you want the name not to belong to any namespace, then use: local-name() = 'type' and not(namespace-uri()) Finally, if you just want the name to be "type" and you do not care about any namespace this name may belong to, use: name() = "type" > Do I need to take care of namespaces? How? It depends on the specific problem you're solving, but usually the answer is positive (otherwise the problem is either very generic or using namespaces in the source.xml was up to no purpose). ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL 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
|