[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] handling tags and PIs within a macro


Subject: Re: [xsl] handling tags and PIs within a macro
From: Nancy Brandt <nancy_brndt@xxxxxxxxx>
Date: Wed, 24 Oct 2007 07:21:26 -0700 (PDT)

Thank you for the explanation, dear Abel.

What I still don't understand is why FOP cannot take
the PCDATA of <fid> element and assign it as an ID to
the formalpara. It is absolutely unclear. May be the
source of the problem is the format of xref to the
formalpara?

For example:
<xref linkend="dhcps_lease_ip" xrefstyle="template:%t
on page %p"/>

where %t is the text of the title of the xreffed
formalpara.

Best regards,
Nancy

--- Abel Braaksma <abel.online@xxxxxxxxx> wrote:

> Nancy Brandt wrote:
> >   <formalpara id="{fid}">  --> This part
> >
> > Why is it important to enclose the "id" part in
> curly
> > brackets?
> 
> That's a way to tell the XSLT processor that inside
> the attribute 
> there's a value that should be interpreted as an
> XPath expression. It is 
> called an Attribute Value Template (or AVT for
> short). You can write:
> 
> <formalpara>
>     <xsl:attribute name="id"><xsl:value-of
> select="fid" /></xsl:attribute>
> </
> 
> Or you can write:
> 
> <formalpara id="{fid}">
> </
> 
> which is quite shorter and closer to what it will
> eventually look like: 
> an element with the "id" attribute set to whatever
> is in inside the 
> 'fid" node (without curlies, this would be the
> literal "fid" string, 
> instead of the content of <fid>). If you, for
> whatever reason, need an 
> explicit { or } inside an attribute, you need to
> double it:
> 
> <formalpara id="{{doublecurlies}}">
> </
> 
> You can use any valid XPath expression. It's result
> will be the 
> string-value of that expression (equal to when you
> would use the 
> xsl:value-of approach instead). Now you may wonder
> why there's still the 
> verbose construct with xsl:attribute, if this is so
> much clearer with an 
> AVT. Well, the short answer is: there are situations
> where an AVT does 
> not suffice. I.e., when you want the name of the
> attribute to be 
> dynamically generated, then, inside the
> xsl:attribute, the @name 
> attribute itself is also an AVT:
> 
> <formalpara>
>     <xsl:attribute name="{attrName}"><xsl:value-of
> select="fid" 
> /></xsl:attribute>
> </
> 
> will create a formalpara element with an attribute
> with the name of 
> whatever is inside the attrName element. If the
> source looked like 
> <attrName>my-jolly-attribute</attrName><fid>Fidelity
> Content</fid> then 
> the output would be
> 
> <formalpara my-jolly-attribute="Fidelity Content">
> </
> 
> 
> HTH,
> Cheers,
> -- Abel Braaksma
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Current Thread
Keywords