Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Getting WordprocessingML p style / was: Re: [xsl] Problem with Positional Grouping from MSXML

From: Yves Forkl <Y.Forkl@------>
To:
Date: 2/2/2007 4:38:00 PM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent