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

Re: Getting WordprocessingML p style

Subject: Re: Getting WordprocessingML p style
From: Florent Georges <darkman_spam@xxxxxxxx>
Date: Fri, 2 Feb 2007 19:13:07 +0100 (CET)
Re:  Getting WordprocessingML p style
Yves Forkl wrote:

  Hi

> I suggest using "=" instead of "eq"

  Mmh, just use eq if you compare an atomic value to an other one, and
= if you test if an atomic value is equal to one of several values,
isn't it?

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

  This makes your function more specialized (it just checks if the p
element matches, mine is a more general accessor).  That may be what
you want, and maybe not.

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

  Depending on your needs, you'll may find the following usefull:

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

  From a sequence of w:p elements, it returns all those whose the style
property is one of the strings passed as second parameter:

    my:p-by-style(ns0:Body/w:p, ('style-1', 'style-2'))

  You can adapt it for your needs.  For example pass it not a sequence
of w:p but one (maybe optional) ns0:Body:

    <xsl:function name="my:p-by-style" as="element(w:p)*">
      <xsl:param name="body"   as="element(ns0:Body)?"/>
      <xsl:param name="styles" as="xs:string*"/>
      <xsl:sequence select="
          $body/w:p[w:pPr/w:pStyle/@w:val = $styles]"/>
    </xsl:function>

  I found this kind of little tool functions very helpfull when you
work on highly rich structured languages.  For example here, the
'style' property of an paragraph is in w:pPr, then w:pStyle, then
@w:val.  You just think "its style", but you have to remember all the
path, with the right namespaces (a nightmare when your data model uses
eavily inheritance in WXS through a plethora of schema documents).

  But the key point is to well choose the functions you'll write, IMHO.
 Too much functions is not helpfull, that just adds complexity to
complexity.

  Regards,

--drkm





















	

	
		
___________________________________________________________________________ 
Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions ! 
Profitez des connaissances, des opinions et des expiriences des internautes sur Yahoo! Questions/Riponses 
http://fr.answers.yahoo.com

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