On Thu, Oct 30, 2008 at 12:43:16PM -0700, Dave Connet wrote: > In generating some xslt, I think I've come across a bug... > test.xml: > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet type="text/xsl" href="test.xsl"?> > <Root PathName="C:\Test Dir\"> > <Note id="Id1"/> > </Root> > > test.xsl > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > <xsl:output method="html" encoding="UTF-8"/> > <xsl:template match="/"> > <xsl:apply-templates /> > </xsl:template> > <xsl:template match="Root"> > <HTML> > <head><title>Header</title></head> > <BODY> > <xsl:value-of select="/Root/@PathName"/><br/>tes > <xsl:apply-templates select="Note"/> > </BODY> > </HTML> > </xsl:template> > <xsl:template match="Note"> > <img> > <xsl:attribute name="width">415</xsl:attribute> > <xsl:attribute name="height">10</xsl:attribute> > <xsl:attribute name="src"><xsl:value-of > select="/Root/@PathName"/>images/myImage.gif</xsl:attribute> > </img> > <xsl:value-of select="@id"/><br/> > </xsl:template> > </xsl:stylesheet> > > Both xalan and IE (browser,v7) produce the same results. xsltproc > doesn't: > Using xalan: > <HTML> > <head> > <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> > <title>Header</title> > </head> > <BODY>C:\Test Dir\<br>tes > <img width="415" height="10" src="C:\Test > Dir\images/myImage.gif">Id1<br> > </BODY> > </HTML> > > Using xsltproc: > <HTML> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> > <title>Header</title> > </head> > <BODY>C:\Test Dir\<br>tes > <img width="415" height="10" > src="C:%5CTest%20Dir%5Cimages/myImage.gif">Id1<br> > </BODY> > </HTML> > > A posting on the xslt list mentioned that this could probably be > considered a bug in libxml2 - and pointed to htmlAttrDumpOutput in > HTMLtree.c.
libxml2 knows that the src attribute of img tag is an URI-Reference and applies the URI-Reference escaping algorithm. Your problem is that what you are giving as src attribute value is a windows path and not an URI-Reference, that's the core of your problem a windows path should not be put as an URI reference in an HTML page. > I'm not sure what the proper fix should be - I know in my case, simply > adding '\' and ' ' to the excluded chars would fix the above. I don't > know what other effects that might have... (and my generating code can > easily change '\' to '/' before generating the xml, needing only the > space added to the excluded chars then) use a file:/// based URI to express your path Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ [email protected] | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
