cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -
i transforming xhtml xhtml, need xslt stylesheet part of resulting document (the stylesheet contained in <script type"text/template">
element. using the xsl:namespace-alias
instruction, works fine in ie, fails in both chrome , firefox.
here relevant code:
<xsl:output doctype-system="about:legacy-compat" omit-xml-declaration="yes" indent="yes" method="html" media-type="application/xhml" encoding="utf-8"/> <xsl:namespace-alias stylesheet-prefix="wxsl" result-prefix="xsl" /> <xsl:template match="head"> <!-- code omitted clarity --> <script type="text/template"> <wxsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:eli="local"> <wxsl:template select="/"> <wxsl:apply-templates /> </wxsl:template> </wxsl:stylesheet> </script> </xsl:copy> </xsl:template>
it outputs desired transformation in ie, xslt processors firefox , chrome not replacing wxsl
prefix xsl
.
mozilla not support it, there open bug report https://bugzilla.mozilla.org/show_bug.cgi?id=213996 that.
as chrome, wrote short test case xhtml input being http://home.arcor.de/martin.honnen/xslt/test2016012402.xml (just short xhtml sample head
add xslt xslt) , stylesheet http://home.arcor.de/martin.honnen/xslt/test2016012401.xsl doing xhtml xhtml transformation, using alias protect xslt , xslt nested xhtml result elements:
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:axsl="http://example.com/xsl-alias" xmlns:axhtml="http://example.com/xhtml-alias" exclude-result-prefixes="xhtml axsl axhtml" xmlns="http://www.w3.org/1999/xhtml"> <xsl:output method="xml" indent="yes"/> <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/> <xsl:namespace-alias stylesheet-prefix="axhtml" result-prefix="#default"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="xhtml:head"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> <axsl:stylesheet version="1.0"> <axsl:template match="/"> <axhtml:p>xslt created paragraph.</axhtml:p> </axsl:template> </axsl:stylesheet> </xsl:copy> </xsl:template> </xsl:stylesheet>
and chrome seems transform fine, console on inspection shows result elements in right namespace:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>test</title> <axsl:stylesheet xmlns:axsl="http://www.w3.org/1999/xsl/transform" version="1.0"><axsl:template match="/"><axhtml:p xmlns:axhtml="http://www.w3.org/1999/xhtml">xslt created paragraph.</axhtml:p></axsl:template></axsl:stylesheet></head> <body> <h1>test</h1> </body> </html>
i have extended test case try execute embedded stylesheet , both edge , chrome able that, see http://home.arcor.de/martin.honnen/xslt/test2016012407.xml, although chrome reasons have not been able identify fails in domcontentloaded
event listener have set up. not seem problem related using xslt insert xslt, when use button run script doing xslt embedded stylesheet, works fine in chrome. firefox obviously, lack of support xsl:namespace-alias
, never finds stylesheet root element able have code feed xsltprocessor
.
Comments
Post a Comment