-
HTML and javascript in XSL style sheet
I produce a HTML output from an XSL stylesheet, and the format I write the
stylesheet is to have normal html, with the XSL tags handling items such
as table rows for the XML data, in between.
eg.
<html>
<head>
</head>
<body>
<p> My Table </p>
<table>
<xsl:for-each select="data">
<tr><td><xsl:value-of select="Name"/></td></tr>
</xsl:foreach>
</table>
</body>
</html>
I have written a form in a similar way, and have a bit of javascript at the
bottom, but am annoyed by the syntax being incorrect for things like '&'
and '<'. One solution is to use
<xsl:text disable-output-escaping="yes">&</xsl:text>
but this is really annoying when I have javascript expressions generated
for each table data like :
<xsl:for-each select="data">
if
(
(field1 != "<xsl:value-of select="Name"/>" <xsl:text disable-output-escaping="yes">&&</xsl:text>
field2=="")
||
(field3 < "10" <xsl:text disable-output-escaping="yes">&&</xsl:text>
field4 >"100")
)
</xsl:for-each>
because everytime there is an '&' or '<', I have to use the above escape
tag, ending up with a lot of unreadable source.
Is there a better way to do this ?
Thanks,
Eric
-
Re: HTML and javascript in XSL style sheet
"Eric Lee" <eric.lee@dcstrans.com> wrote:
>
>I produce a HTML output from an XSL stylesheet, and the format I write the
>stylesheet is to have normal html, with the XSL tags handling items such
>as table rows for the XML data, in between.
>
>eg.
>
><html>
><head>
></head>
>
><body>
><p> My Table </p>
><table>
>
><xsl:for-each select="data">
><tr><td><xsl:value-of select="Name"/></td></tr>
></xsl:foreach>
>
></table>
></body>
></html>
>
>I have written a form in a similar way, and have a bit of javascript at
the
>bottom, but am annoyed by the syntax being incorrect for things like '&'
>and '<'. One solution is to use
>
><xsl:text disable-output-escaping="yes">&</xsl:text>
>
>but this is really annoying when I have javascript expressions generated
>for each table data like :
>
><xsl:for-each select="data">
>
>if
>(
>(field1 != "<xsl:value-of select="Name"/>" <xsl:text disable-output-escaping="yes">&&</xsl:text>
> field2=="")
>
>||
>(field3 < "10" <xsl:text disable-output-escaping="yes">&&</xsl:text>
> field4 >"100")
>
>)
>
></xsl:for-each>
>
>because everytime there is an '&' or '<', I have to use the above escape
>tag, ending up with a lot of unreadable source.
>
>Is there a better way to do this ?
>
>Thanks,
>
>Eric
>
Check out something like .... <![CDATA[ stuff ]]>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks