DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Eric Lee Guest

    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">&amp;</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">&amp;&amp;</xsl:text>
    field2=="")

    ||
    (field3 < "10" <xsl:text disable-output-escaping="yes">&amp;&amp;</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


  2. #2
    John Galilee Guest

    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 ]]>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links