jelovirt / org.lwdita

LwDITA parser for DITA-OT
http://lwdita.org/
Apache License 2.0
25 stars 19 forks source link

SAXNotRecognizedException when converting Markdown using Saxon 12.2 #185

Closed DunaMariusCosmin closed 10 months ago

DunaMariusCosmin commented 1 year ago

Hi! I use LwDITA with Saxon 12.2 for converting Markdown to DITA like this:

String mdText = 
        "# Markdown Sample\n" + 
        "\n" + 
        "## First section\n" + 
        "Some content inside *first section*.\n" + 
        "";

    XMLReader reader = new MarkdownReader();
    InputSource is = new InputSource(new StringReader(mdText));
    is.setSystemId("fake.md");
    Source src = new SAXSource(reader, is);
    StringWriter sw = new StringWriter();
    Result res = new StreamResult(sw);
    Transformer newTransformer = TransformerFactoryImpl.newInstance().newTransformer();
    newTransformer.transform(src, res);
    sw.close();
    String dita = sw.toString();

When I run this code the following exception is thrown: org.xml.sax.SAXNotRecognizedException: Property http://xml.org/sax/properties/lexical-handler not supported

It seems that Saxon set this property here: net.sf.saxon.resource.ActiveSAXSource.deliver(Receiver, ParseOptions).

Maybe you should ignore it on this method: com.elovirta.dita.markdown.MarkdownReader.setProperty(String, Object)

jelovirt commented 10 months ago

This should be fixed in Saxon because Saxon doesn't catch SAXNotRecognizedException when setting a property. Added support for all SAX built-in properties and features, just ignore them.