DOCTYPE in XSL-stylesheet while using XMLDOM with JScript

X

xq386

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) );
}
 
M

Martin Honnen

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.
 
X

xq386

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!
 
M

Martin Honnen

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top