Menu

#25 XmlPullParserException with empty node

Beta05
closed
XML Parsing (1)
2015-02-27
2014-12-05
No

When connecting a BICEPSClient with a BICEPSDevice we get an XmlPullParserException on the client if the last node of an xml tree is empty.

This examples explains:

<MetaData>
<Manufacturer>manu</Manufacturer>
<ModelName>model</ModelName>
<ModelNumber>12345</ModelNumber>
<SerialNumber></SerialNumber>
</MetaData>

If SerialNumber is empty an XmlPullParserException occurs. The same ecxeption is thrown if writing an xml like this:

<MetaData>
<Manufacturer>manu</Manufacturer>
<ModelName>model</ModelName>
<ModelNumber></ModelNumber>
</MetaData>

No exception is thrown if all nodes contain a string.

Stacktrace on the client
Don't be confused of the position the exception complains about (<d:availability>1</). That's not the relevant position.</d:availability>

org.xmlpull.v1.XmlPullParserException: expected START_TAG or END_TAG not TEXT (position: TEXT seen ...<d:availability>1</... @1:2392)
at org.xmlpull.mxp1.MXParser.nextTag(MXParser.java:1083)
at org.ws4d.java.io.xml.AbstractElementParser.nextTag(AbstractElementParser.java:368)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.parse1(DefaultSOAP2ParameterValueConverter.java:368)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.handleComplexType(DefaultSOAP2ParameterValueConverter.java:201)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.parse0(DefaultSOAP2ParameterValueConverter.java:135)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.handleComplexType(DefaultSOAP2ParameterValueConverter.java:213)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.parse0(DefaultSOAP2ParameterValueConverter.java:135)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.handleComplexType(DefaultSOAP2ParameterValueConverter.java:213)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.parse0(DefaultSOAP2ParameterValueConverter.java:135)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.handleComplexType(DefaultSOAP2ParameterValueConverter.java:213)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.parse0(DefaultSOAP2ParameterValueConverter.java:135)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2ParameterValueConverter.parseParameterValue(DefaultSOAP2ParameterValueConverter.java:54)
at com.draeger.medical.mdpws.communication.protocol.soap.generator.MDPWSSOAP2ParameterValueConverter.parseParameterValue(MDPWSSOAP2ParameterValueConverter.java:99)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2MessageGenerator.deliverBody(DefaultSOAP2MessageGenerator.java:297)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2MessageGenerator.deliver(DefaultSOAP2MessageGenerator.java:560)
at com.draeger.medical.mdpws.communication.protocol.soap.generator.MDPWSSOAP2MessageGenerator.deliver(MDPWSSOAP2MessageGenerator.java:297)
at org.ws4d.java.communication.protocol.soap.generator.DefaultSOAP2MessageGenerator.deliverMessage(DefaultSOAP2MessageGenerator.java:166)
at org.ws4d.java.communication.protocol.soap.SOAPRequest$1.handle(SOAPRequest.java:235)
at org.ws4d.java.communication.protocol.http.HTTPClient$StreamConsumerThread.run(HTTPClient.java:1164)
at org.ws4d.java.concurrency.DefaultThreadPool$WorkerThread.run(DefaultThreadPool.java:303)</d:availability>

Discussion

  • Stefan Schlichting

    Thanks for reporting.

    I am trying to reproduce the reported bug, but I have problems with it.

    I assume that the Metadata you showed is from a HydraMDSDescriptor. If I look into the generated XML it should look like this:

    <d:MetaData>
        <d:Manufacturer lang="en">manu</d:Manufacturer>
        <d:ModelName lang="en">model</d:ModelName>
        <d:ModelNumber>1</d:ModelNumber>
    </d:MetaData>
    

    Even when I am setting the serial number of the metadata to an empty list.

    So my question is: How did you get to the XML that is processed? Would be great to see the code and maybe the complete message.

     
  • Stefan Schlichting

    Code sniipet how the MetaData is produced:

        private SystemMetaData createMetaData() {
            SystemMetaData metaData=new SystemMetaData();
    
            List<LocalizedText> manu=new ArrayList<LocalizedText>();
            LocalizedText manuText=new LocalizedText();
            manuText.setValue("manu");
            manu.add(manuText);
            metaData.setManufacturer(manu);
    
            List<LocalizedText> model=new ArrayList<LocalizedText>();
            LocalizedText modelText=new LocalizedText();
            modelText.setValue("model");
            model.add(modelText);
            metaData.setModelName(model);
    
            List<String> number=new ArrayList<String>();
            number.add(Integer.toString(12345));
            metaData.setModelNumber(number);
    
            List<String> serial=new ArrayList<String>();
            serial.add(null);
            metaData.setSerialNumber(serial);
    
            return metaData;
        }
    
     
  • Nikolaj Weise

    Nikolaj Weise - 2014-12-05

    Yes, it's a HydraMDSDescriptor. I use an xml file device description. Do you use java for creating a device? Maybe the error occurs only when using xml.
    Maybe you know the "openSDC_Konnektor" from "Uni_Rostock-KarlStorz-ORNET rundumSorglosPaket". That's the device I'm talking about.

    This is my xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <MDIBContainer xmlns="http://www.draeger.com/projects/DSC/CMDM/2012/05" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.draeger.com/projects/DSC/CMDM/2012/05 BICEPS_MessageInformationModel.xsd">
        <MDDescription>
            <MDS xsi:type="HydraMDSDescriptor" Handle="md0">
                <Type>
                    <CodingSystemId>urn:oid:1.3.6.1.4.1.3592</CodingSystemId>
                    <CodeId>MySimpleMDSCode</CodeId>
                </Type>
                <MetaData>
                    <Manufacturer>KS and Uni Rostock</Manufacturer>
                    <ModelName>power LED 175</ModelName>
                    <ModelNumber>100E</ModelNumber>
                    <SerialNumber></SerialNumber>
                </MetaData>
                <Context Handle="h_context"></Context>
                <SCO Handle="_scoHandlemd0">
                    <Operation xsi:type="SetValueOperationDescriptor" Handle="handle_lightintensity_set" OperationTarget="handle_lightintensity" />
                    <Operation xsi:type="ActivateOperationDescriptor" Handle="handle_increase" OperationTarget="handle_lightintensity">
                        <Type>
                            <CodeId>MDC_INCREASE_VALUE</CodeId>
                        </Type>
                    </Operation>
                    <Operation xsi:type="ActivateOperationDescriptor" Handle="handle_decrease" OperationTarget="handle_lightintensity">
                        <Type>
                            <CodeId>MDC_DECREASE_VALUE</CodeId>
                        </Type>
                    </Operation>
                </SCO>
                <VMD Handle="vmd0">
                    <Type>
                        <CodeId>VMDTypeCode</CodeId>
                    </Type>
                    <Channel Handle="c0md0">
                        <Type>
                            <CodeId>ChannelTypeCode</CodeId>
                        </Type>
                        <Metric xsi:type="NumericMetricDescriptor" Handle="handle_lightintensity">
                            <Type>
                                <CodeId>MDC_LIGHTSOURCE_INTENSITY</CodeId>
                            </Type>
                            <Unit>
                                <CodeId>MDC_PER_CENT</CodeId>
                            </Unit>
                            <MetricCategory>2</MetricCategory>
                            <Availability>1</Availability>
                            <Retrievability>1</Retrievability>
                            <Retrievability>2</Retrievability>
                            <Retrievability>3</Retrievability>
                            <Resolution>5</Resolution>
                            <TechnicalRange Lower="0" Upper="100" StepWidth="5"></TechnicalRange>
                        </Metric>
                        <AlertSystem Handle="alertSystem">
                            <AlertCondition Handle="alertCondition">
                                <ConditionCode>
                                    <CodeId>MY_ALERT_CONDITION_CODE</CodeId>
                                </ConditionCode>
                                <Kind>1</Kind>
                                <Source>handle_lightintensity</Source>
                                <Priority>0</Priority>
                                <Info>
                                    <InfoCode>
                                        <CodeId>SOME_INFO_CODE</CodeId>
                                    </InfoCode>
                                </Info>
                            </AlertCondition>
                            <AlertCondition Handle="alertCondition2">
                                <ConditionCode>
                                    <CodeId>MY_ALERT_CONDITION_CODE</CodeId>
                                </ConditionCode>
                                <Kind>1</Kind>
                                <Source>handle_lightintensity</Source>
                                <Priority>1</Priority>
                                <Info>
                                    <InfoCode>
                                        <CodeId>SOME_INFO_CODE</CodeId>
                                    </InfoCode>
                                </Info>
                            </AlertCondition>
                            <AlertSignal Handle="alertSignal">
                                <ConditionSignaled>alertCondition</ConditionSignaled>
                                <Manifestation>1</Manifestation>
                                <IsLatching>false</IsLatching>
                            </AlertSignal>
                            <AlertSignal Handle="alertSignal2">
                                <ConditionSignaled>alertCondition2</ConditionSignaled>
                                <Manifestation>1</Manifestation>
                                <IsLatching>false</IsLatching>
                            </AlertSignal>
                        </AlertSystem>
                    </Channel>
                </VMD>
            </MDS>
        </MDDescription>
        <MDState/>
    </MDIBContainer>
    
     
  • Stefan Schlichting

    Could you attach it as a file?

    BTW Which openSDC version is it? Beta04?

     

    Last edit: Stefan Schlichting 2014-12-05
  • Nikolaj Weise

    Nikolaj Weise - 2014-12-05

    I'm sorry, I haven't seen the "add attachments" link.
    It is Beta04.

     
  • Stefan Schlichting

    I will give it a try with the example file.

     
  • Stefan Schlichting

    • status: open --> accepted
    • assigned_to: Stefan Schlichting
     
  • Stefan Schlichting

    Will be fixed in Beta05.

     
  • Stefan Schlichting

    • labels: --> XML Parsing
     
  • Stefan Schlichting

    • status: accepted --> closed
    • Milestone: Beta04 --> Beta05
     

Log in to post a comment.

MongoDB Logo MongoDB