xsl-list
[Top] [All Lists]

Re: [xsl] selecting w:p nodes based on w:pStyle attributes

2006-03-27 15:20:48

Here is one of the templates I have tried. With this one, I get the 
original source :

Are you sure? I just tried it and the source is modified by the 
   <xsl:template match="w:p/w:pPr/w:pStyle[(_at_)w:val = 'NL']">
    <xsl:copy-of select="ancestor::w:p/node()"/>
    <xsl:apply-templates/>
    </xsl:template>

as I'd have expected.

Unfortunately you over-clipped your input file so it wasn't well formed,
so I'll post a well formed version so that you can see the result:


<x    xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml";>

<w:p>
       <w:pPr>
         <w:pStyle w:val="A-Head"/>
       </w:pPr>
       <w:r>
         <w:t>Nouns</w:t>
       </w:r>
</w:p>
<w:p>
       <w:pPr>
         <w:pStyle w:val="NL"/>
       </w:pPr>
       <w:r>
         <w:t>blah blah blah</w:t>
       </w:r>
</w:p>

</x>


Using the stylesheet exactly as you posted I get the following

$ saxon wp.xml wp.xsl
<?xml version="1.0" encoding="utf-8"?><x
xmlns:w="http://schemas.microsoft.com/o
ffice/word/2003/wordml">

<w:p>
       <w:pPr>
         <w:pStyle w:val="A-Head"/>
       </w:pPr>
       <w:r>
         <w:t>Nouns</w:t>
       </w:r>
</w:p>
<w:p>
       <w:pPr>

       <w:pPr>
         <w:pStyle w:val="NL"/>
       </w:pPr>
       <w:r>
         <w:t>blah blah blah</w:t>
       </w:r>

       </w:pPr>
       <w:r>
         <w:t>blah blah blah</w:t>
       </w:r>
</w:p>

</x>


Note that this isn't the same as the input, "blah blah blah" is repeated,
and you have a w:pPr and w:r inside the second w:pPr.

this is because

This matched your NL w:pStyle element
   <xsl:template match="w:p/w:pPr/w:pStyle[(_at_)w:val = 'NL']">

This copied all the children of the ancestor w:p, which in this case is a
    w:pPr element and a w:r element
    <xsl:copy-of select="ancestor::w:p/node()"/>

This did nothing as it applies templates to the children of pStyle, but
    there are none.
    <xsl:apply-templates/>

    </xsl:template>


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--