Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Getting WordprocessingML p style

From: Florent Georges <darkman_spam@-------->
To:
Date: 2/2/2007 6:13:00 PM
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


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