My problem is WebKit cannot handle xslt document() method when i use javascript to do xslt processing. When I include xsl file in xml and call xml file from browser it work. But when I use javascript to handle this process, it crashes. I have to use javascript to pass parameters to xsl file. So I cannot live without javascript. Here is html part.
<html>
<head>
<script language="javascript" src="./js/jquerymin.js"></script>
<script language="javascript" src="./js/jquery.transform.js"></script>
<script>
$(document).ready(function(){
$("#example").transform({xml:"sample.xml", xsl:"sample.xsl", xslParams:{scan:'system',sub:'lan'}});
});
</script>
</head>
<body >
<div id="example" ></div>
</body>
</html>
Here is basic xsl file which crashes with this approach:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:nsm="http://xxxxx.com/yyyyy/system"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:param name="scan" select="'system'"/>
<xsl:param name="sub" select="'lan'"/>
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:variable name="xsdFile" select="document('sample.xsd')"/>
<xsl:for-each select="$xsdFile">
ssss
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
As I said it does not work while I let javascript to do transformation.But when I call xml file from browser it works.
Is this a bug or I miss something here?
Thanks,
edit: http://plugins.jquery.com/project/Transform this is the jquery plugin I use. By the way other browsers such as firefox and opera can handle both ways quite perfect
xsl:value-of select="$xsdfile"
it displays the xsd file contents. but i cannot apply xpath on it like$xsdfile/xs:schema/child::*
– savruk Mar 15 '11 at 14:45<value-of select="$xsd"/>
it prints[object Document]
on webkit and nothing on others. but when i use<value-of select="$xsd/xs:schema/xs:element[@name='info']"/>
it gives the expected output on others but not on WebKit – savruk Mar 15 '11 at 16:11/
operator)works on others, it means that you are passing a node set for others. If the XML Schema document doesn't have text nodes, then the correct string value would be an empty string, never would be[object Document]
unless Webkit is casting the parameter to string and that operation onDocument
objects result in such string. – user357812 Mar 15 '11 at 16:20