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

attribute value templates & javascript entities, etc

Subject: attribute value templates & javascript entities, etc
From: Jim Palmer <jpalmer@xxxxxxxxxxxx>
Date: Sun, 27 Jun 1999 12:27:36 -0700
javascript attribute value
Sorry if this is obvious, but I looked in the archives for a solution
and didn't see it. Thanks  in advance.

-- Jim Palmer
Manager, Human Interface
Liberate Technologies, Inc.
650-631-5237
http://www.liberate.com

----------------------------------------------------------------------------------------------------

Problem 1: Imagine you need an HTML attribute such as BACKGROUND to be
computed in a page's run time context. So I want to use a javascript
entity in the final HTML (though javascript is not essential to the
problem):

<BODY BACKGROUND="&{backgroundUrl}" ... >

The following naive solution doesn't work

 <xsl:template match="/">
  <HTML>

  <HEAD>
  <TITLE></TITLE>
   <SCRIPT>
        var backgroundUrl = foo();
    </SCRIPT>
  </HEAD>

  <BODY background = "&{backgroundUrl};">
     Whatever
  </BODY>

  </HTML>
 </xsl:template>

presumably since "&" isn't in the HTML name space except for HTML
entities (such as &amp;) and "{}" are for attribute value templates in
xsl.

Is there some obvious way to get the literal text in there
(xsl:constant?).

Variant: Lets say the some part of the body HTML needs to be decided at
run time; I have no problem in general including javascript in the
output (or any other elements not in the HTML namespace) -- they come
out fine -- _except_ when I have to document.write the HTML (I
understand that this may be impossible due to nested quoting, etc.) --
the xsl continues to try to parse the HTML. Assume that all the HTML
tags do match:

 <xsl:template match="/">
  <HTML>

  <HEAD>
  <TITLE></TITLE>
   <SCRIPT>
        var fullScreen = foo();
    </SCRIPT>
  </HEAD>

  <BODY>

        <SCRIPT>
             if (fullScreen)
                document.write(
                  '<FORM NAME="buttons" />',
                  '<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"
/>',
                  '<TR>',
                  '<TD><SPACER TYPE="horizontal" SIZE="12" /></TD>',

                    ...
                )
            else
                document.write(  .... )

        </SCRIPT>
  </BODY>

  </HTML>
 </xsl:template>

I invariably get "tags don't match" type errors, even though they do.




 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.