xsl-list
[Top] [All Lists]

RE: XMLFilter in a URIResolver

2003-09-11 06:38:36
When you supply a SAXSource to Saxon, Saxon sets the properties of the
XMLReader supplied with the SAXSource to make sure that it is reporting
namespaces in the way that Saxon requires. Specifically it does:

        parser.setFeature("http://xml.org/sax/features/namespaces";,
true);
 
parser.setFeature("http://xml.org/sax/features/namespace-prefixes";,
false);

A SAX2 parser is expected to recognize these properties; if it responds
to these requests with an exception, Saxon complains with the error
message that you saw.

Your XMLFilter is pretending to be a SAX2 parser, so it must support
these methods properly.

Michael Kay


-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Andrew Welch
Sent: 11 September 2003 14:03
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] XMLFilter in a URIResolver


Create a SAXSource, whose InputSource is the actual XML file, and
whose
XMLReader is the XMLFilter. Return the SAXSource as the 
result of the 
URIResolver.

(untested)

Thanks Mike,

I now get the error,

Warning: The SAX2 parser does not support a required namespace feature

Which I guess is related to the XMLFilter, which looks like:

public void startElement(String namespaceURI, String 
localName, String qualifiedName, Attributes atts) throws 
SAXException {

 AttributesImpl newAttributes = new AttributesImpl(atts);  
newAttributes.addAttribute("", "elementID", "elementID", "",
counter+"");
 atts = newAttributes;
 counter++;
        
 super.startElement(namespaceURI, localName, qualifiedName, atts); }

This method simply adds @elementID to each element.


The code that calls this (in the resolver) is:

SAXSource s = new SAXSource();
s.setInputSource(new InputSource(is));
s.setXMLReader(addElementIdToXML);   
return s;

I'm using Saxon 7.6.5a and crimson.  Do I need to set the 
XMLReader on the XMLFilter??  Or am I missing the point?  
When I do set it, the XMLFilter seems to be ignored.  When 
its not set, I get the error. Surely I need to set it...

Still confused,

andrew



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>