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

selecting w:p nodes based on w:pStyle attributes

Subject: selecting w:p nodes based on w:pStyle attributes
From: Terry Ofner <tofner@xxxxxxxxxxx>
Date: Mon, 27 Mar 2006 16:41:42 -0500
w pstyle
I am trying to select w:p nodes based on w:pStyle attribute. At first I was getting no traction because I didn't have all the MS Word namespace prefixes assigned. Now that I have that issue addressed, I need help with predicates. The p:Style node is a child of the w:p node which I want to select and copy to the result tree. Here is an example of the XML:
...


<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>

...

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

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
    xmlns:o="urn:schemas-microsoft.com:office:office"
    xmlns:aml="http://schemas.microsoft.com/aml2001/core">

  <xsl:template match="@*|node()">
	<xsl:copy>
		<xsl:apply-templates select="@*|node()"/>
	</xsl:copy>
</xsl:template>


<xsl:template match="w:p/w:pPr/w:pStyle[@w:val = 'NL']"> <xsl:copy-of select="ancestor::w:p/node()"/> <xsl:apply-templates/> </xsl:template>

</xsl:stylesheet>

I know that "w:p/w:pPr/w:pStyle[@w:val = 'NL']" works to select the particular attribute. For example, when I run the template below, I get repeated <w:pStyle w:val = "NL" > nodes in the result tree with nothing else.

 <xsl:template match="w:p"/>
   <xsl:apply templates select="w:pPr/w:pStyle[@w:val = 'NL']"/>

</xsl:template>

What am I doing wrong?

Terry

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.