![]() |
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 "€"> ]> --> <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"/> <!-- € --> </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) ); } |
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/ |
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! |
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.