You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Patrick Moore <pa...@rioport.com> on 2001/03/15 01:03:32 UTC

Possible Bug or possible misunderstanding

Hi there -- 

I am not certain about what is correct handling of whitespace when defining
an attribute. In the W3C XSL document it talks about putting a newline in
the middle of an attribute definition results in the attribute have the
newline encoded as &#xA;

I have an XSL stylesheet transform source XML document and a SAX
ContentHandler deal with the resulting output. (See below for that code).
The XSL attribute definition looks like this:

     <xsl:attribute name="x">
         <xsl:value-of =select="...." />
    </xsl:attribute>

Now what I am seeing is rather puzzling. If I just do the transformation and
output the result to a file (I do not involve the SAXContentHandler)  There
are no leading/trailing spaces. But when I use the SAXContentHandler it does
see spaces in the attribute. It seems like the behavior is inconsistent and
to be try to the w3c spec the attribute should have the leading/trailing
whitespace encoded.

Thanks --

---Pat


main code:

		TransformerFactory factory =
TransformerFactory.newInstance();
		if ( !factory.getFeature(SAXResult.FEATURE) ) {
			throw new SAXException("Not a SAXTransformer");
		}
		SAXTransformerFactory xsltf = (SAXTransformerFactory)
factory;
		TransformerHandler th = xsltf.newTransformerHandler(new
StreamSource(xslFilename.openStream()));
		XMLHandler ch = getXMLHandler();
		ch.put(XMLHandler.DATAHANDLER, this.dataHandler);
		th.setResult(new SAXResult(ch));
		XMLReader reader = XMLReaderFactory.createXMLReader();
		reader.setContentHandler(th);
	
reader.setProperty("http://xml.org/sax/properties/lexical-handler", th);
		reader.parse(new InputSource(xmlFilename.openStream()));

RE: Possible Bug or possible misunderstanding

Posted by Christian Aberger <Ch...@Aberger.at>.
Hi,

I also had this problem, and I worked around it with the following:
	<xsl:attribute name="x">
		<xsl:value-of =select="...." />
<xsl:text>
</xsl:text>
</xsl:attribute>

This puts the whitespace linefeed in. I do neither know if this is correct
or not, but I am interested in the answer on this topic, because if there
are changes expected in this behaviour in future versions I must take care
change these some hundred places before upgrading to a newer version of
Xalan. I want the Xalan html output nicely formatted, in contrast to the
output of some tools (Vrondbaige, Inderdef etc).

wfR ChrisA

-----Original Message-----
From: Patrick Moore [mailto:patrickm@rioport.com]
Sent: Donnerstag, 15. März 2001 01:04
To: Xalan (E-mail)
Subject: Possible Bug or possible misunderstanding


Hi there --

I am not certain about what is correct handling of whitespace when defining
an attribute. In the W3C XSL document it talks about putting a newline in
the middle of an attribute definition results in the attribute have the
newline encoded as &#xA;

I have an XSL stylesheet transform source XML document and a SAX
ContentHandler deal with the resulting output. (See below for that code).
The XSL attribute definition looks like this:

     <xsl:attribute name="x">
         <xsl:value-of =select="...." />
    </xsl:attribute>

Now what I am seeing is rather puzzling. If I just do the transformation and
output the result to a file (I do not involve the SAXContentHandler)  There
are no leading/trailing spaces. But when I use the SAXContentHandler it does
see spaces in the attribute. It seems like the behavior is inconsistent and
to be try to the w3c spec the attribute should have the leading/trailing
whitespace encoded.

Thanks --

---Pat


main code:

		TransformerFactory factory =
TransformerFactory.newInstance();
		if ( !factory.getFeature(SAXResult.FEATURE) ) {
			throw new SAXException("Not a SAXTransformer");
		}
		SAXTransformerFactory xsltf = (SAXTransformerFactory)
factory;
		TransformerHandler th = xsltf.newTransformerHandler(new
StreamSource(xslFilename.openStream()));
		XMLHandler ch = getXMLHandler();
		ch.put(XMLHandler.DATAHANDLER, this.dataHandler);
		th.setResult(new SAXResult(ch));
		XMLReader reader = XMLReaderFactory.createXMLReader();
		reader.setContentHandler(th);

reader.setProperty("http://xml.org/sax/properties/lexical-handler", th);
		reader.parse(new InputSource(xmlFilename.openStream()));