|
Subject: Re: [xsl] Getting WordprocessingML p style From: Florent Georges <darkman_spam@xxxxxxxx> Date: Fri, 2 Feb 2007 19:13:07 +0100 (CET) |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Getting WordprocessingML p st, Yves Forkl | Thread | Re: [xsl] Getting WordprocessingML , David Carlisle |
| Re: [xsl] Problem with Positional G, David Carlisle | Date | Re: [xsl] Saxon auto-recognition of, Florent Georges |
| Month |