Unparsed-entity-uri issue
Added by Anonymous over 19 years ago
Legacy ID: #3299277 Legacy Poster: Matt B (mrbarringer)
I'm using Saxon 8.4 with a Java application and I'm having a problem getting with the unparsed-entity-uri() function. If I use a transformer created from a TransformerFactory with a StreamSource input, the function works fine and returns the SYSTEM identifier for a graphic entity within the XML document. However, when I switch to using a transformer initiated through a SAXTransformerFactory (and thus SAX input), the unparsed-entity-uri() function will only return an empty string. I've tried using both the Crimson and Xerces parsers and that hasn't made a difference in the results. Do I need to somehow tie in an XMLReader DTDHandler to Saxon to get the entity function to work, or is there something else I'm missing?
Replies (2)
RE: Unparsed-entity-uri issue - Added by Anonymous over 19 years ago
Legacy ID: #3300654 Legacy Poster: Michael Kay (mhkay)
When you get a TransformerHandler from a SAXTransformerFactory, it acts as a SAX ContentHandler. Unfortunately certain events, such as comments and unparsed entities, aren't notified to the ContentHandler: comments are notified to the LexicalHandler, and unparsed entities to the DTDHandler. The TransformerHandler in fact implements all three of these interfaces. You're probably doing what the TraxExamples sample application does: TransformerHandler handler = stfactory.newTransformerHandler(new StreamSource(xslID)); // Create a reader, and set it's content handler to be the TransformerHandler. XMLReader reader = makeXMLReader(); reader.setContentHandler(handler); but you should really be nominating the handler as a LexicalHandler and a DTDHandler as well, so that it gets all these events notified by the parser. Michael Kay
RE: Unparsed-entity-uri issue - Added by Anonymous over 19 years ago
Legacy ID: #3300781 Legacy Poster: Matt B (mrbarringer)
Arghhh!! You nailed it. I actually had the handler set up as a LexicalHandler and had added an EntityResolver for the reader, but forgotten to set up the handler as a DTDHandler!! Thanks, Matt
Please register to reply