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

SPIN/DOM-XML-01035 - SpinXmlElement.elementList() fails on empty xml list #16

Open
Brutus5000 opened this issue Aug 3, 2017 · 1 comment

Comments

@Brutus5000
Copy link

Brutus5000 commented Aug 3, 2017

Used packages:
camunda-spin-core:1.3.1
camunda-spin-dataformat-all:1.3.1

When I call elementList() on an empty XML tag I expect the get an empty list.

In the following you find 4 calls:

XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List><Item/></List>").xPath("//List/node()").elementList();
XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List> </List>").xPath("//List/node()").elementList();
XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List></List>").xPath("//List/node()").elementList();
XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List/>").xPath("//List/node()").elementList();

The first is my reference and returns 1 element in the list.
Calls 2-4 are equal in XML semantics. The only difference is that Call 2 contains a whitespace between the tags.
However, only the second call returns an empty list. Call 3 & 4 throw a SpinXPath expression, even though the xPath call itself does not throw the error - elementList() throws the error.

org.camunda.spin.xml.SpinXPathException: SPIN/DOM-XML-01035 Unable to find XPath expression '//List/node()'

at org.camunda.spin.impl.xml.dom.DomXmlLogger.unableToFindXPathExpression(DomXmlLogger.java:176)
at org.camunda.spin.impl.xml.dom.util.DomXmlEnsure.ensureXPathNotEmpty(DomXmlEnsure.java:83)
at org.camunda.spin.impl.xml.dom.query.DomXPathQuery.elementList(DomXPathQuery.java:79)
at [my code]

@Brutus5000
Copy link
Author

Workaround: check for the presence of subnodes first:

    SpinXmlElement xml = XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><List></List>");
    if(xml.xPath("count(//List/*)").number() > 0 ) {
        xml.xPath("//List/node()").elementList();
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant