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

Re: XSL stylesheet issue (newbie)

Subject: Re: XSL stylesheet issue (newbie)
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 17 Oct 2024 17:40:57 -0000
Re:  XSL stylesheet issue (newbie)
On 17/10/2024 19:22, Frank Dissinger frank.dissinger@xxxxxxxxxxxx wrote:
> Hello everyone,
>
> The stylesheet below is supposed to add a unique 'id' attribute named
'tocref001', 'tocref002' etc. to all <h2>, <h3> and <p class="rn_heading">
elements which are descendants of an element with an 'id' attribute named
'rn_release_notes'. The script runs without any errors, but does not add any
IDs.


The sample input has e.g.

 B  html xmlns="http://www.w3.org/1999/xhtml"

meaning it has elements in the XHTML namespace, if you use an XSLT 2 or
3 processor like Saxon Java, SaxonJS, SaxonC or Saxon.NET you can add

 B  xpath-default-namespace="http://www.w3.org/1999/xhtml"

on your xsl:stylesheet element in the XSLT code and your match

>
> <!-- Adding id=toc001 attributes to headings to create hyperlink targets for
the TOC -->
> <xsl:template match="*[@id='rn_release_notes']//h2 |
*[@id='rn_release_notes']//h3 |
*[@id='rn_release_notes']//p[@class='rn_heading']">
>

will match XHTML elements.

But with an XSLT 1 processor the h2 and h3 or any unqualified element
name matches such an element in *no* namespace, so your input elements
are not matched.

With XSLT 1, in the XSLT you would need to bind a prefix (e.g. `xhtml`)
to the namespaceB  with a proper namespace declaration

 B  xmlns:xhtml="http://www.w3.org/1999/xhtml"

and then qualify all XHTML element names with that prefix e.g.

 B B  <xsl:template match="*[@id='rn_release_notes']//xhtml:h2 |
*[@id='rn_release_notes']//xhtml:h3 |
*[@id='rn_release_notes']//xhtml:p[@class='rn_heading']">

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.