[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: hoe to use "(" within a variable

Subject: Re: hoe to use "(" within a variable
From: Sergey Groznyh <gsm@xxxxxx>
Date: Tue, 13 Aug 2002 11:18:54 +0400
ant escape quote
>>>>> "Jeni" == Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> writes:

    Jeni> use single quotes, as follows:

    Jeni> <xsl:variable name="entering_log"
    Jeni> select='&apos;sprintf(log_str, "\n%s: %d: %s: %s", __FILE__,
    Jeni> __LINE__, fn, "Entering"); log_func();&apos;' />

    Jeni> or you could use double quotes and escape the double quotes
    Jeni> in the attribute value, as follows:

    Jeni> <xsl:variable name="entering_log" select="'sprintf(log_str,
    Jeni> &quot;\n%s: %d: %s: %s&quot;, __FILE__, __LINE__, fn,
    Jeni> &quot;Entering&quot;); log_func();'" />

Also, it's almost always a bad idea to generate code in some language
*directly* from XSLT: you will always have to escape things, and as a
result, XSLT code will not look very readable.  Instead, you may
represent output as a [subset of] target language grammar, like this:

    <stmtseq>
      <stmt>
        <funcall>
          <name>sprintf</name>
          <arglist>
            <arg type="ident">log_str</arg>
            <arg type="string">\n%s: %d: %s: %s</arg>
            <arg type="ident">__FILE__</arg>
            <arg type="ident">__LINE__</arg>
            <arg type="ident">fn</arg>
            <arg type="string">Entering</arg>
          </arglist>
        </funcall>
      </stmt>
      <stmt>
        <funcall>
          <name>log_func</name>
          <void />
        </funcall>
      </stmt>
    </stmtseq>

and allow simple external processor to serialize resulting XML to
actual C code.

-- 
SM Groznyh                            "Under the wide and heavy VAX
gsm@xxxxxx                             Dig my grave and let me relax..."

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.