HTML and javascript in XSL style sheet


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: HTML and javascript in XSL style sheet

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


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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center