jelovirt/org.lwdita

SAXNotRecognizedException when converting Markdown using Saxon 12.2

DunaMariusCosmin opened this issue · 1 comments

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)

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.