Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in Xerces when Match.transform() doesn't produce any nodes #166

Open
lukaseder opened this issue Sep 19, 2019 · 0 comments

Comments

@lukaseder
Copy link
Member

When using Match.transform(), we can get NullPointerException when the argument XSL does not produce any nodes

Consider this program:

public static void main(String[] args) throws Exception {
    Match xml = JOOX.$(QOM.class.getResourceAsStream("/xml.xml"));
    System.out.println(xml);

    Match result = xml.transform(QOM.class.getResourceAsStream("/xsl.xsl"));
    System.out.println(result);
}

And the stylesheet might have no templates that match, e.g.

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output encoding="UTF-8" method="html" omit-xml-declaration="yes" indent="yes"/>
</xsl:stylesheet>

Then, this will be the result:

Exception in thread "main" java.lang.NullPointerException
	at java.xml/com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1536)
	at java.xml/com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1501)
	at org.joox.Impl.transform(Impl.java:1889)
	at org.joox.Impl.transform(Impl.java:1900)
	at org.joox.Impl.transform(Impl.java:1909)
	at org.joox.Impl.transform(Impl.java:79)
	at org.jooq.qom.QOM.main(QOM.java:49)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant