DOCTYPE in XSL-stylesheet while using XMLDOM with JScript

Discussion in 'XML' started by xq386@hotmail.com, Mar 12, 2007.

  1. Guest

    Question: In the XSL file below I put a part of the code
    (concerning the euro-sign) in comment. If I remove the
    comment then it doesn't work anymore. How can this be solved?

    I run Test.html with Internet Explorer on Window-XP.
    Below I give all the files I'm using.

    Look at following code:

    File: Test.html

    <html>
    <head>
    <script language="javascript" src="z_transform.js"></script>
    </head>
    <body>
    <script language="javascript">
    myXml = "test.xml";
    myXsl = "test.xsl";
    transformXsl();
    </script>
    </body>
    </html>


    File: Test.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <test amount="20.4">
    </test>


    File: Test.xsl

    <?xml version="1.0"?>
    <!--
    <!DOCTYPE xsl:stylesheet
    [
    <!ENTITY euro "€">
    ]>
    -->
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
    Transform">
    <xsl:eek:utput method="html"/>
    <xsl:template match="/">
    Amount = <xsl:value-of select="/test/@amount"/>
    <!-- &euro; -->
    </xsl:template>
    </xsl:stylesheet>


    File: z_transform.js

    function transformXsl()
    {
    var rSourceDoc,rStyleDoc;

    rSourceDoc = new ActiveXObject("microsoft.xmldom");
    rSourceDoc.async="false";
    rSourceDoc.load(myXml);

    rStyleDoc = new ActiveXObject("microsoft.xmldom");
    rStyleDoc.async="false";
    rStyleDoc.load(myXsl);

    document.write(rSourceDoc.transformNode(rStyleDoc) );
    }
    , Mar 12, 2007
    #1
    1. Advertising

  2. wrote:

    > function transformXsl()
    > {
    > var rSourceDoc,rStyleDoc;
    >
    > rSourceDoc = new ActiveXObject("microsoft.xmldom");
    > rSourceDoc.async="false";


    rSourceDoc.async = false;

    > rSourceDoc.load(myXml);
    >
    > rStyleDoc = new ActiveXObject("microsoft.xmldom");
    > rStyleDoc.async="false";


    rStyleDoc.async = false;
    As your XSL contains an incomplete DTD you need to set
    rStyleDoc.validateOnParse = false;
    to sucessfully load and transform.

    > rStyleDoc.load(myXsl);
    >
    > document.write(rSourceDoc.transformNode(rStyleDoc) );
    > }
    >


    Note that XML and XSLT as an XML application fully support Unicode so
    there is no need to define entities like euro, you can just use the
    character itself "€" like I do in this post.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 12, 2007
    #2
    1. Advertising

  3. Guest

    On 12 mrt, 15:56, Martin Honnen <> wrote:
    > Note that XML and XSLT as an XML application fully support Unicode so
    > there is no need to define entities like euro, you can just use the
    > character itself "€" like I do in this post.
    >
    >         Martin Honnen
    >        http://JavaScript.FAQTs.com/


    The problem is not the €, but how to use ENTITIES in this situation!
    , Mar 13, 2007
    #3
  4. wrote:

    > The problem is not the €, but how to use ENTITIES in this situation!


    As I said, if you set
    rStyleDoc.async = false;
    rStyleDoc.validateOnParse = false;
    then you can load your stylesheet with the entity declarations.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 13, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Sommer
    Replies:
    0
    Views:
    422
    Thomas Sommer
    Nov 25, 2004
  2. MC
    Replies:
    1
    Views:
    7,235
    David Carlisle
    Mar 24, 2005
  3. Replies:
    0
    Views:
    520
  4. Ben Fidge

    Sorting XML using XMLDOM without using XSL

    Ben Fidge, Dec 9, 2005, in forum: ASP General
    Replies:
    0
    Views:
    105
    Ben Fidge
    Dec 9, 2005
  5. Larry Lindstrom
    Replies:
    19
    Views:
    1,271
    Jonathan N. Little
    Jun 12, 2012
Loading...

Share This Page