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

Subject: RE: [xsl] xsl-list question: import precedence with strip-space
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 11 Jan 2010 22:04:25 -0000
strip-space and preserve-space act like template rules: given an element,
the processor looks for the highest-precedence strip-space or preserve-space
rule that tells it what to do with that element. Saying strip-space
elements="p" doesn't override strip-space elements="*": it tells the
processor what to do with p elements, and says nothing about any other
elements, so the processor keeps searching and finds the elements="*" rule.
To override strip-space elements="*" you need preserve-space elements="*".

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  

> -----Original Message-----
> From: Lynn Murdock [mailto:lmurdock@xxxxxxxx] 
> Sent: 11 January 2010 21:43
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] xsl-list question: import precedence with strip-space
> 
> hi-
> 
> i'm new to this forum, so hope this is the correct procedure 
> for posting.
> 
> 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.
> 
> 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.  i have been 
> able to fix the problem by adding 'p' to the 
> <xsl:preserve-space> element, but am wondering why the 
> strip-space instruction in the importing document doesn't 
> seem to have precedence over that in the imported document.  
> does anyone know why i'm getting the results i am 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), or whether 
> adding 'p' to the preserve-space instruction is my best option?
> 
> in case it helps, here are the instructions in the importing document:
>     <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
>         "/>
> 
> and the imported document:
>   <xsl:strip-space elements="*"/>
> 
> 
> thanks a lot!
> 
> lynn

Current Thread