You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Alex Z <az...@comcast.net> on 2002/11/19 23:35:52 UTC

xml declaration appearance inside attribute values? (long)

This is a "has anybody ever seen this?" post.

Occasionally, we'll have a situation where our transformed xml -> html will 
appear, for example, like this:

<a href="<?xml%20version=%221.0%22%20encoding=%22UTF-8%22?>">Some text</a>

Now, there wasnt any magic in our xsl:

<xsl:template match="a">
  <a><xsl:attribute name="href"><xsl:value-of 
select="@href"/></xsl:attribute><xsl:apply-templates/></a>
</xsl:template>

It doesn't only happen for a tags -- it also happens with others, such as img 
src attributes.

Some notes:
In the code, when the above symptom is spotted, I've tried throwing out the 
Templates object we've cached, so that the next thread will create a new one; 
however, the problem does not go away until the system is restarted.

Since this in an intermittent issue, I suspected that there could be some 
concurrency issue.  Our app server will have numerous threads running at the 
same time doing transformations, so I made sure our code followed the pattern on 
the multithreading documentation on xml.apache.org/xalan-j/, as well as the 
additional synchronization of calling TransformerFactory.newInstance and 
<instance>.newTemplates.  If anyone thinks posting my code or full xsl would be 
useful I will do so.

We're running Xalan 2.4.1 w/ packaged Xerces 2.2.  (although this has happened 
with every version of Xalan we've run, going back to at least 2.1) and JDK 
1.2.1_04.

Any suggestions?

Thanks,
Alex


Re: xml declaration appearance inside attribute values? (long)

Posted by Joseph Kesselman <ke...@us.ibm.com>.
Apologies for hasty misreading. Bad habit of mine...

The brief answer is that I can't think of any reason for the XML 
Declaration to wind up in the attribute value. I'd need to see the 
specific stylesheet and input file which produced this output, both to 
check that there isn't something odd in your stylesheet and to analyse 
what Xalan is doing in response to it... and to confirm that the glitch 
really is in Xalan rather than some earlier or later processing stage. 
(Call me paranoid if you like, but I honestly can't think of any way Xalan 
*could* produce that output accidentally.)

______________________________________
Joe Kesselman  / IBM Research

Re: xml declaration appearance inside attribute values? (long)

Posted by Alex Z <az...@comcast.net>.
Sorry, I think I didn't emphasize the problem enough - it isnt the uri escapes, 
  its the <?xml version="1.0" encoding="UTF-8"?> appearing mysteriously inside 
an attribute that bothers me.

Alex


Joseph Kesselman wrote:
> Correct operation per the XSLT spec. In HTML output mode, attributes which 
> are known to always contain URI references must be escaped to make them 
> compatable with the URI specs -- which means some characters, including 
> space, must be escaped.
> 
> ______________________________________
> Joe Kesselman  / IBM Research
> 



Re: xml declaration appearance inside attribute values? (long)

Posted by Joseph Kesselman <ke...@us.ibm.com>.
Correct operation per the XSLT spec. In HTML output mode, attributes which 
are known to always contain URI references must be escaped to make them 
compatable with the URI specs -- which means some characters, including 
space, must be escaped.

______________________________________
Joe Kesselman  / IBM Research