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

Re: How to generate a path expression which shows the

Subject: Re: How to generate a path expression which shows the namespace that each element on the path belongs to and the namespace that each namespace prefix is bound to?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 5 Feb 2021 16:54:16 -0000
Re:  How to generate a path expression which shows the
Use the fn:path() function in XPath 3.x.

Michael Kay
Saxonica

> On 5 Feb 2021, at 16:36, Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi Folks,
>
> I have an XHTML document. Here is an example:
>
> <html xmlns:o="urn:schemas-microsoft-com:office:office"
>           xmlns="http://www.w3.org/TR/REC-html40">
>    <head>
>        <title>Example</title>
>    </head>
>    <body>
>        <p>
>            <o:p></o:p>
>        </p>
>    </body>
> </html>
>
> I want to show the path to each element. I can iterate over all nodes and
use ancestor-or-self along with string-join to show the path:
>
> <xsl:for-each select="//*">
>    <xsl:value-of select="string-join(for $i in (ancestor-or-self::*) return
name($i), '/')"/>
> </xsl:for-each>
>
> Here is one of the paths that is generated:
>
> html/body/p/o:p
>
> Unfortunately, that path expression is missing crucial information:
>
> - html, body, p are in the http://www.w3.org/TR/REC-html40 namespace
> - the "o" prefix is bound to the urn:schemas-microsoft-com:office:office
namespace
>
> It is vital that I have that information because I want to generate XHTML
instances from the path expressions. For example, for the above path
expression I will generate:
>
> <html xmlns="http://www.w3.org/TR/REC-html40"
>           xmlns:o="urn:schemas-microsoft-com:office:office">
>    <body>
>        <p>
>            <o:p></o:p>
>        </p>
>    </body>
> </html>
>
> How to generate a path expression which shows the namespace that each
element on the path belongs to and the namespace that each namespace prefix is
bound to?
>
> /Roger

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.