Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   DOCTYPE in XSL-stylesheet while using XMLDOM with JScript (http://www.velocityreviews.com/forums/t483580-doctype-in-xsl-stylesheet-while-using-xmldom-with-jscript.html)

xq386@hotmail.com 03-12-2007 12:45 PM

DOCTYPE in XSL-stylesheet while using XMLDOM with JScript
 
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 "&#x20AC;">
]>
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:output 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) );
}


Martin Honnen 03-12-2007 02:56 PM

Re: DOCTYPE in XSL-stylesheet while using XMLDOM with JScript
 
xq386@hotmail.com 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/

xq386@hotmail.com 03-13-2007 12:30 PM

Re: DOCTYPE in XSL-stylesheet while using XMLDOM with JScript
 
On 12 mrt, 15:56, Martin Honnen <mahotr...@yahoo.de> 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!


Martin Honnen 03-13-2007 12:39 PM

Re: DOCTYPE in XSL-stylesheet while using XMLDOM with JScript
 
xq386@hotmail.com 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/


All times are GMT. The time now is 07:23 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.