carrying xml name spaces across nested elements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Datawich

    carrying xml name spaces across nested elements


    Hi. By persistence, I've discovered that when several nested elements
    in a schema are each qualified by a namespace, I can successfully
    reference them in a select statement by qualifying each element by its
    namespace in succession. For example, for a schema that qualfies each
    element in a nested series "command, heading, pivot table" by "xs", I
    can use an xpath statement like "//xs:command/xs:heading/
    xs:pivotTable" to select the pivot table node.

    I figure that when all the name space qualifications are identical,
    there's some way to carry the namespace across all the elements
    without typing exact same one for each separately. Is there? If so,
    could someone tell me what it is?

    Thanks for any help!
  • Martin Honnen

    #2
    Re: carrying xml name spaces across nested elements

    Datawich wrote:
    Hi. By persistence, I've discovered that when several nested elements
    in a schema are each qualified by a namespace, I can successfully
    reference them in a select statement by qualifying each element by its
    namespace in succession. For example, for a schema that qualfies each
    element in a nested series "command, heading, pivot table" by "xs", I
    can use an xpath statement like "//xs:command/xs:heading/
    xs:pivotTable" to select the pivot table node.
    >
    I figure that when all the name space qualifications are identical,
    there's some way to carry the namespace across all the elements
    without typing exact same one for each separately. Is there? If so,
    could someone tell me what it is?
    With XSLT 2.0 and XPath 2.0 there is an XPath default namespace that you
    can set e.g.
    <xsl:styleshe et
    xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    version="2.0"
    xpath-default-namespace="http ://example.com/2008/ns1">

    <xsl:template match="/">
    <xsl:value-of select="//command/heading/pivotTable"/>
    so that way you don't need a prefix.

    Is that what you have in mind, avoiding to type the prefix 'xs'?

    XSLT and XPath 2.0 are not supported by Microsoft products but there are
    third party implementations , Saxon from
    <URL:http://saxon.sourcefor ge.net/has a .NET and a Java version,
    AltovaXML <URL:http://www.altova.com/altovaxml.htmli s a COM solution,
    Gestalt <URL:http://gestalt.sourcef orge.net/has binaries for different
    platforms.


    --

    Martin Honnen --- MVP XML

    Comment

    Working...