Skip to content

Commit

Permalink
[bugfix] Set the Lexical Handler when parsing Stylesheets
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed Nov 29, 2024
1 parent 5c33fcd commit 3af6653
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;

/**
* {@link org.xml.sax.XMLReader} that uses an {@link org.exist.storage.serializers.Serializer}
Expand Down Expand Up @@ -102,7 +103,7 @@ public void parse(final InputSource input) {
try {
this.source = input;
this.contentHandler.setDocumentLocator(this);
serializer.setSAXHandlers(this.contentHandler, null);
serializer.setSAXHandlers(this.contentHandler, this.contentHandler instanceof LexicalHandler ? (LexicalHandler)this.contentHandler : null);
serializer.toSAX(source.getDocument());
}
catch (SAXParseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.Constants;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;

import static org.exist.xslt.XsltURIResolverHelper.getXsltURIResolver;

Expand Down Expand Up @@ -159,7 +160,7 @@ private <E extends Exception> Templates compileTemplates(

final Serializer serializer = broker.borrowSerializer();
try {
serializer.setSAXHandlers(handler, null);
serializer.setSAXHandlers(handler, handler instanceof LexicalHandler ? (LexicalHandler)handler : null);
serializer.toSAX(stylesheet);
} finally {
broker.returnSerializer(serializer);
Expand Down

0 comments on commit 3af6653

Please sign in to comment.