[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] xsl-list question: import precedence with strip-space


Subject: Re: [xsl] xsl-list question: import precedence with strip-space
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 11 Jan 2010 16:50:23 -0500

At 2010-01-11 13:42 -0800, Lynn Murdock wrote:
i'm new to this forum,

Welcome!


so hope this is the correct procedure for posting.

Indeed it is.


i am using <xsl:import> to import a generic stylesheet into a more specific stylesheet. i'm getting an apparent conflict between the <xsl:strip-space> instructions in the importing and imported documents: the 'elements' attribute of the importing document contains a list of elements; the 'elements' attribute of the imported document contains '*', and it appears that either the instruction in the importing document is being ignored or the instructions from both documents are being used.

Both are being used. Per XSLT 2.0 section 4.4, any element not matched in the importing stylesheet elements= attribute patterns is a candidate to be matched in the imported stylesheet elements= attribute patterns.


So, yes, anything not in the list in the importing stylesheet is still being caught by the imported stylesheet.

in the resulting transformation, whitespace is stripped between adjacent tags within a paragraph, eg:
</italic> <ext-link>
becomes
</italic><ext-link>


when i had this error previously in just the importing document, removing 'p' from the list of strip-space elements fixed the problem. but now i suspect that the '*' from the imported document is removing that space again.

Indeed it is, per the specification.


i have been able to fix the problem by adding 'p' to the <xsl:preserve-space> element,

That is one correct way to override a lower-importance use of elements="*".


but am wondering why the strip-space instruction in the importing document doesn't seem to have precedence over that in the imported document.

It does, but only on a pattern-by-pattern basis. The wording in the specification is:


"any match with lower import precedence than another match is ignored"

does anyone know why i'm getting the results i am

It is in the specification as you are experiencing.


and whether there's a way to force only the importing document's strip-space instruction to be used (without commenting out or changing anything in the imported document),

Yes, you should be able to do the following by totally shutting down the imported <xsl:strip-space> by using the same pattern in an importing <xsl:preserve-space> and then using an importing <xsl:strip-space> with more specific patterns than the wildcard used for preservation ... to wit:


    <xsl:preserve-space elements="*"/>
    <xsl:strip-space elements="abstract ack address annotation app app-group
        array article article-categories article-meta article-title
        author-comment author-notes back bio body boxed-text
        break caption chem-struct chem-struct-wrapper
        citation col colgroup conference contrib contrib-group
        copyright-statement date def def-item def-list
        disp-quote etal fig fig-group fn fn-group front
        gloss-group glossary glyph-ref graphic history hr
        inline-graphic journal-meta kwd-group list list-item
        media mml:math name nlm-citation note notes page-count
        person-group private-char pub-date publisher ref
        ref-list response sec speech statement sub-article
        subj-group supplementary-material table table-wrap
        table-wrap-foot table-wrap-group tbody term tfoot thead
        title-group tr trans-abstract verse-group
        "/>

In the above the simple names have a priority of 0 and the wildcard has a priority of -.5, so the names win out.

or whether adding 'p' to the preserve-space instruction is my best option?

You could do that, but you state that you want to shut down the imported <xsl:strip-space> which is done as described above.


I hope this helps.

. . . . . . . . . . . . . . Ken

--
UBL and Code List training:      Copenhagen, Denmark 2010-02-08/10
XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
XSLT/XQuery/XPath training:   San Carlos, California 2010-04-26/30
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


Current Thread
Keywords