8.6.1: attribute types not copied
Added by Anonymous almost 19 years ago
Legacy ID: #3585968 Legacy Poster: Werner Donné (wdonne)
Hi, If I create a chain of three XMLFilters, putting the result of SAXTransformerFactory.newXMLFilter() in the middle with a copying style steet, and if I parse a document with a DTD which declares attributes with type ID, then I see the correct attribute types in the first filter, but not in the third one. Regards, Werner.
Replies (6)
Please register to reply
RE: 8.6.1: attribute types not copied - Added by Anonymous almost 19 years ago
Legacy ID: #3586168 Legacy Poster: Michael Kay (mhkay)
Fom your description, I don't think this should happen. Could you please submit a test case that demonstrates the problem? Michael Kay
RE: 8.6.1: attribute types not copied - Added by Anonymous almost 19 years ago
Legacy ID: #3586811 Legacy Poster: Werner Donné (wdonne)
Here is a small test-programme and an input document: --- import java.io.; import javax.xml.parsers.; import javax.xml.transform.; import javax.xml.transform.sax.; import javax.xml.transform.stream.; import org.xml.sax.; import org.xml.sax.helpers.*; public class Test { public static void main(String[] args) throws Exception { SAXTransformerFactoryfactory = (SAXTransformerFactory) TransformerFactory.newInstance(); XMLFilterfirst = new TestFilter(); XMLFilterlast = new TestFilter(); XMLReaderreader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); XMLFiltertransformer = factory.newXMLFilter(new StreamSource(new File(args[0]))); last.setParent(transformer); transformer.setParent(first); first.setParent(reader); last.parse(new InputSource(new FileInputStream(args[1]))); } private static class TestFilter extends XMLFilterImpl { public void startElement ( StringnamespaceURI, StringlocalName, StringqName, Attributesatts ) throws SAXException { System.out.println(qName + ": "); for (int i = 0; i < atts.getLength(); ++i) { System.out.println(" " + atts.getQName(i) + ": " + atts.getType(i)); } super.startElement(namespaceURI, localName, qName, atts); } } // TestFilter } // Test --- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> h1#test { background-color: red; } </style> </head> <body> <h1 id="test">Test</h1> </body> </html> --- Werner.
RE: 8.6.1: attribute types not copied - Added by Anonymous almost 19 years ago
Legacy ID: #3586953 Legacy Poster: Michael Kay (mhkay)
Thanks. You haven't supplied the stylesheet. How are you copying the nodes? With the stylesheet <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> I get the following output, which suggests the IDness of the attributes is being copied. html: head: title: style: type: CDATA xml:space: NMTOKEN body: h1: id: ID html: head: title: style: type: CDATA xml:space: CDATA body: h1: id: ID
RE: 8.6.1: attribute types not copied - Added by Anonymous almost 19 years ago
Legacy ID: #3586990 Legacy Poster: Werner Donné (wdonne)
Oh indeed, I forgot the style sheet. This is it: <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8" omit-xml-declaration="no"/> <xsl:template match="@|node()"> <xsl:copy> <xsl:apply-templates select="@|node()"/> </xsl:copy> </xsl:template> </xsl:transform> Werner.
RE: 8.6.1: attribute types not copied - Added by Anonymous almost 19 years ago
Legacy ID: #3587126 Legacy Poster: Michael Kay (mhkay)
Thanks. There is an inconsistency, I think, in the specification. It relates to the open issue 2700 http://www.w3.org/Bugs/Public/show_bug.cgi?id=2700 though it is a slightly different angle on the problem. There is a lack of clarity in the spec about exactly when the is-id and is-idrefs properties of a node are retained. The spec for xsl:copy (section 11.9.1) says fairly clearly that these properties are copied. However, section 19.2 says that with validation="strip", which is the default, type annotations are dropped, and this would normally imply that the is-id property is dropped too. There doesn't seem to be any obvious reason why xsl:copy and xsl:copy-of are behaving differently in Saxon. But I think I'll wait until the decisions have been made on issue 2700 before making any changes to the code. Thanks for raising it: it's interesting that it should come up in practice at the same time as the WG is discussing the theory. Michael Kay The
RE: 8.6.1: attribute types not copied - Added by Anonymous almost 19 years ago
Legacy ID: #3587707 Legacy Poster: Werner Donné (wdonne)
Thanks Michael. It is indeed best to wait for the outcome of issue 2700. In the meantime users can specify version 2.0 and use the "default-validation" attribute for example. With that set to "preserve" it works and makes it explicit. Regards, Werner.
Please register to reply