|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: Re: EXSL's dyn:evaluate() and XALAN vs. xsl:us
I would prefer a more compact solution, avoiding the possibly long and
difficult to maintain xsl:choose.
Something like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:myAttribs="my:Attribs" exclude-result-prefixes="myAttribs">
<xsl:output method="html"/>
<myAttribs:myAttribs>
<test1 font-family="sans-serif" font-weight="bold"/>
<spacer1 font-family="roman" font-weight="normal"/>
</myAttribs:myAttribs>
<xsl:variable name="vAttribs"
select="document('')/*/myAttribs:*"/>
<xsl:template match="text">
<p>
<xsl:copy-of
select="$vAttribs/*[name() = current()/@attribs]/@*"/>
<xsl:apply-templates/>
</p>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the following source.xml:
<t>
<text attribs="test1">XXX</text>
<text attribs="spacer1">YYY</text>
</t>
the wanted result is produced:
<p font-family="sans-serif" font-weight="bold">XXX</p>
<p font-family="roman" font-weight="normal">YYY</p>
Hope this helped.
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
<raphead@xxxxxxx> wrote in message news:8300.1061728037@xxxxxxxxxxxxxxxx
> > >A simple example: Why not include an top-level element belonging to a
> > > non-xsl
> > >namespace and having the necessary attributes. Then you can just copy
> them.
> > >
> >
> > I thought about that but I don't think that this is an solution. Right!
> I
> > could dynamically
> > decide depending on a parameter to do something - in case of copy: copy
> some
> > xml to the
> > current position. But this won't fix my problem as I'm working with fo
> and
> I
> > need exactly
> > the behaviour of the use-attribute-sets parameter which creates
> attributes
> > from a XML-fragment.
> >
> > Now I thought about using call-template but it has the same limitation:
> The
> > name must be
> > qname :-/
>
> Then you'll gradually find that the same effect can be achieved with
> xsl:apply-templates
>
> For details see:
>
>
http://fxsl.sourceforge.net/articles/FuncProg/Functional%20Programming.html
>
>
> I really doubt that in this concrete case you really need so much power,
> as
> I have not seen your source xml document and do not know what the
> transformation must do.
>
I think I with Michaels and your hints, I got it!
on every occurence of the relevant attribute, I'm caling a Template with the
value of the attribute. The called template decides with a switch-case like
structure
what attributes to create:
The called template looks like that.
<xsl:template name="definitions">
<xsl:param name="selector"/>
<xsl:choose >
<xsl:when test="$selector='test1'">
<xsl:attribute name="font-family">sans-serif</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:when>
<xsl:when test="$selector='spacer1#">
<xsl:attribute name="font-family">sans-serif</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>
Thanks for your help!
>
> =====
> Cheers,
>
> Dimitre Novatchev.
> http://fxsl.sourceforge.net/ -- the home of FXSL
>
--
COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test
--------------------------------------------------
1. GMX TopMail - Platz 1 und Testsieger!
2. GMX ProMail - Platz 2 und Preis-Qualitätssieger!
3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








