XInclude set in AugmentedSource is "sticky"
Added by Anonymous over 15 years ago
Legacy ID: #7410432 Legacy Poster: David Lee (daldei)
I believe this is a core bug in Saxon 9. If I create an AugmentedSource and set the XInclude feature (lke this) AugmentedSource as = AugmentedSource.makeAugmentedSource(s); as.setXIncludeAware(true); Then use this source for an S9API call such as xquery, xslt or xpath then xincludes are properly expanded. However the NEXT document I create without using an augmented source also gets xincludes expanded. I have tracked this down to 2 areas in saxon core. 1) xinclude property for the underlying parser is only turned "on" not "off". In the Sender class, the xinclude property is examined and only if it is "on" does the feature get set in the underlying parser. ( this would be OK if not for #2 ) 2) Parsers appear to be cached in the configuration. The underlying parser's features for xinclude are not "unset" when parsers are reused. In the Configuration class, getSourceParser() will re-use a cached parser. The underlying (xerces) xinclude feature is not reset so the previous value for that feature is maintained. The end result is that once I set xinclude on a single AugmentedSource, that setting stays on for all future sources, even if xinclude is off in both the Configuration object and the AugmentedSource Workaround suggestions ? Maybe a way of clearing the parser cache, or making a copy of the Configuration ? Thank you for any ideas -David
Replies (2)
RE: XInclude set in AugmentedSource is "sticky" - Added by Anonymous over 15 years ago
Legacy ID: #7410445 Legacy Poster: Michael Kay (mhkay)
Yes, there have been other similar problems with parser caching - someone was supplying a parser whose EntityResolver was set, and found that before reusing the parser, the EntityResolver gets unset. It's a messy area of the design, unfortunately. It's often difficult to fix this kind of thing properly without a redesign that affects backwards compatibility, but I'll give it some thought.
RE: XInclude set in AugmentedSource is "stick - Added by Anonymous over 15 years ago
Legacy ID: #7410549 Legacy Poster: David Lee (daldei)
Thanks for the thoughts. I have tried out this workaround, and it appears to work. The "goal" is to avoid using the parser pool for xincluded documents, I first tried copying the configuration then discovered it copies the pool too. So instead I'm forcing an explicit parser on the AugmentedSource. This seems to work. Do you see any obvious problems in doing this ? I only found a few cases in Saxon where the AugmentedSource.setXMLReader() was used so I dont know if I'm missing some kind of pre-setup it requires. // Use a reader manually created so that it doesnt get stuck in the pool XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); AugmentedSource source = AugmentedSource.makeAugmentedSource(stdin.asSource(opts)); source.setXIncludeAware(true); source.setXMLReader(reader); XdmNode node = processor.newDocumentBuilder().build(source); Thanks. -David
Please register to reply