[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XPath matching elements with or without prefix by inh

Subject: XPath matching elements with or without prefix by inherited namespace
From: "Stephen Colin (UK)" <Colin.Stephen@xxxxxx>
Date: Fri, 11 Jan 2008 14:54:31 -0000
 XPath matching elements with or without prefix by  inh
I'm sure this must be a common problem, but I've been unable to find any
reference to it.

How do I reliably match the "elem" element in both of the below
documents:

<?xml version="1.0" encoding="UTF-8?>
<p:example xmlns:p="something">
  <elem>value</elem>
</p:example>

<?xml version="1.0" encoding="UTF-8?>
<p:example xmlns:p="something">
  <p:elem>value</p:elem>
</p:example>

I believe that these are effectively identical as the prefix on elem in
the latter case is
redundant and same the namespace definition is inherited from p:example.

However the following will only match one and not the other (as though
the latter cases had no namespace associated with the <elem>).

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsmlns:q="something">
<xsl:template>
  <xsl:value-of select="//elem"/>
</xsl:template>
</xsl:stylesheet>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsmlns:q="something">
<xsl:template>
  <xsl:value-of select="//q:elem"/>
</xsl:template>
</xsl:stylesheet>

I'm confused, as if I use some xslt to show the namespaces on the node
in each case their identical:

 xml -> http://www.w3.org/XML/1998/namespace
 p   -> something

I get the same result with either Saxon 6.5.3 or xsltproc -
libxml(20628), libxslt(10120), libexslt(813)

I'm wanting to use XPath expressions to robustly handle SOAP requests in
either form.

Is it that only the definitions are inherited and the child elements
need to have the prefix to be explicitly put into that namespace ?

Many thanks,

Colin

--
Colin Stephen
ISD - Data Delivery Development Team (DDT)
Tel: +44 (0) 1753 564534
Mob: +44 (0) 7801 850728




This electronic message contains information from O2 which may be privileged
or confidential. The information is intended to be for the use of the
individual(s) or entity named above. If you are not the intended recipient be
aware that any disclosure, copying distribution or use of the contents of this
information is prohibited. If you have received this electronic message in
error, please notify us by telephone or email (to the numbers or address
below) immediately.

Switchboard: +44 (0)113 272 2000
O2 (UK) Limited 260 Bath Road, Slough, Berkshire SL1 4DX Registered in England
and Wales: 1743099. VAT number: GB 778 6037 85

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.