[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Selecting Specific Elements Regardless of Namespac
Lindy,
What you're saying is confusing since the term "namespace" does not match the example you gave. //fruit/apples/grannysmith/apple does not match an apple element in a fruit namespace. A fruit element is an ancestor (here, great-grandparent) of an apple element, but they are both in the same namespace (here, whatever namespace has no prefix). If your source has something like <fruit xmlns="www.fruit.com"> <apples> <grannysmith> <apple>...</apple> </grannysmith> </apples> </fruit> I guess you could say the apple is in the fruit namespace, whereas in <fruit xmlns="www.vegetables.com"> <apples> <grannysmith> <apple>...</apple> </grannysmith> </apples> </fruit> it's not. Is this what you mean? If so, you can distinguish by setting up distinctive namespace bindings in your stylesheet to distinguish between the fruit and vegetables namespaces. E.g. <xsl:template xmlns:fruit="www.fruit.com" xmlns:veggies="www.vegetables.com"> <xsl:value-of select="//fruit:fruit"/> </xsl:template> gets you the value of the first fruit element in the www.fruit.com namespace. To get the first fruit element regardless of its namespace, the trick you first had, //*[local-name()='fruit'] is something of a hack, but serviceable. Since XPath had no expression to say "in any namespace", things do get tricky here and the hack is justifiable. To get a fruit element regardless of a namespace but making sure it's a child of a jonathan, also regardless of what namespace the jonathan is in, you could do //*[local-name()='jonathan']/*[local-name()='apple'] But that's pretty unfortunate. As you can see, the namespace mechanism isn't really designed to support type-identity of elements across namespaces; in fact, just the opposite. Is that closer? Cheers, Wendell At 03:13 PM 5/9/2002, you wrote: That isn't quite the answer to my question. I am needing to do this regardless of the namespace. Let me go into a little more detail ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== 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
|