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

Getting WordprocessingML p style / was: Re: Prob

Subject: Getting WordprocessingML p style / was: Re: Problem with Positional Grouping from MSXML
From: Yves Forkl <Y.Forkl@xxxxxx>
Date: Fri, 02 Feb 2007 17:37:26 +0100
 Getting WordprocessingML p style / was: Re:  Prob
Florent Georges wrote:

  <xsl:function name="my:p-style" as="xs:string">
    <xsl:param name="p" as="element()"/>
    <xsl:sequence select="$p/w:pPr/w:pStyle/@w:val"/>
  </xsl:function>

Thank you, Darkman, for contributing this style sheet function which is indeed very useful for checking a paragraph's style in WordprocessingML in a call like this:


<xsl:template match="w:p[my:p-style(.) eq 'BodyHeading']">
...

I suggest using "=" instead of "eq", because of the general comparison behaviour of "=" (described here: http://www.w3.org/TR/xpath20/#id-general-comparisons - thank you and MK for this URL!). It thus allows to test against several styles at once, when they are contained in a sequence:

<xsl:template
  match="w:p[my:p-style(.) = ('Heading5', 'Heading6')]">
...

As a matter of taste, I prefer putting the comparison operator rather inside the function definition than into each call:

<xsl:function name="my:match-p-style" as="xs:boolean">
  <xsl:param name="node" as="element()"/>
  <xsl:param name="styles"/>
  <xsl:value-of select="$node/w:pPr/w:pStyle/@w:val = $styles"/>
</xsl:function>


<xsl:template match="w:p[my:match-p-style(., 'BodyHeading')]"> ...

<xsl:template
  match="w:p[my:match-p-style(., ('Heading5', 'Heading6'))]">
...


Has somebody further improvements to suggest, which might perhaps reduce the amount of redundant code even more?


Yves

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