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

Re: [xsl] curly braces in attributes


Subject: Re: [xsl] curly braces in attributes
From: Jakub Malý <jakub@xxxxxxx>
Date: Tue, 24 Apr 2012 12:32:26 +0200

Doubling the curly braces fixes the problem.
I think the question also requires an explanation: curly braces in
attributes of literals (and also some xslt instructions) are used to
mark attribute value templates
(http://www.w3.org/TR/xslt#attribute-value-templates). These allows to
put a result of an expression inside a value of an attribute (e.g.
link="xxx{1+1}" would output link="xxx2". In your case, {basedir} is
an attribute value template, expression basedir is evaluated and in
your context, it returns an empty sequence, which is serialized into
an empty string.
Jakub.

On Sat, Apr 21, 2012 at 12:16 AM, Mansour Al Akeel
<mansour.alakeel@xxxxxxxxx> wrote:
> thank you for everyone.
>
>
> On Fri, Apr 20, 2012 at 5:40 PM, Hermann Stamm-Wilbrandt
> <STAMMW@xxxxxxxxxx> wrote:
>> Interesting, doubling the curly braces seems to do what you want:
>>
>> $ echo "<foobar/>" | xsltproc curly.xsl -
>> <target name="clean"><delete dir="${basedir}/target"/></target>
>> $
>> $ cat curly.xsl
>> <xsl:stylesheet version="1.0"
>> B xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>
>> B <xsl:output omit-xml-declaration="yes" />
>>
>> B <xsl:template match="/">
>> B  B <target name="clean" >
>> B  B  B <delete dir="${{basedir}}/target" />
>> B  B </target>
>> B </xsl:template>
>>
>> </xsl:stylesheet>
>> $
>>
>> Mit besten Gruessen / Best wishes,
>>
>> Hermann Stamm-Wilbrandt
>> Level 3 support for XML Compiler team and Fixpack team lead
>> WebSphere DataPower SOA Appliances
>> https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
>> ----------------------------------------------------------------------
>> IBM Deutschland Research & Development GmbH
>> Vorsitzende des Aufsichtsrats: Martina Koederitz
>> Geschaeftsfuehrung: Dirk Wittkopp
>> Sitz der Gesellschaft: Boeblingen
>> Registergericht: Amtsgericht Stuttgart, HRB 243294
>>
>>
>>
>> B From: B  B  B  Mansour Al Akeel <mansour.alakeel@xxxxxxxxx>
>>
>> B To: B  B  B  B  xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>,
>>
>> B Date: B  B  B  04/20/2012 11:27 PM
>>
>> B Subject: B  B [xsl] curly braces in attributes
>>
>>
>>
>>
>>
>>
>> I am trying to generate xml that contains attributes with with curly
>> braces.
>> My style sheet has something like:
>>
>> B B B  B B B  <target name="clean" >
>> B B B  B B B  B  B  B <delete dir="${basedir}/target" />
>> B B B  B B B  </target>
>>
>> The results I am getting now is:
>>
>> B B B  <target name="clean" >
>> B B B B B B B  <delete dir="$/target"/>
>> B B B  </target>
>>
>> I am expecting the same to output the same text. I tried to use
>> <xsl:text> and CDATA. The only way I was able to get the output I
>> needed is using CDATA inside <xsl:text> for the parts,
>> I need to output unchanged and unescaped.
>>
>> Is there a better to disable expression evaluation. Thank you.


Current Thread
Keywords