Doh! That should be:
MCCIMT000100HT02MessageDocument message =
MCCIMT000100HT02MessageDocument.Factory.parse(inputFile);
Dave H.
Dave Harrison wrote:
>Peter-Paul,
>
>I guess in your Schema you have MCCI_MT000100HT02.Message specified as a
>type, then an element of that type as the root element of document
>instances. The problem is that you are parsing the file using the
>MCCIMT000100HT02Message.Factory, and not the
>MCCIMT000100HT02MessageDocument.Factory. The xxxDocument is the instance
>of the document.
>
>Try the following:
>
>String file = "D:/Htb/Dev/message/EE07_xmlbean.xml";
>File inputFile = new File(file);
>try
> {
> MCCIMT000100HT02MessageDocument message =
> MCCIMT000100HT02Message.Factory.parse(inputFile);
> String ext = message.getMCCIMT000100HT02Message().getId().getExtension();
> System.out.println(ext);
>...
>
>
>This should do what you were expecting.
>
>Dave H.
>
>Peter-Paul Rang wrote:
>
>
>
>>I don't see a problem with this elementFormDefault
>>
>>a default namespace has been defined in the xml file:
>>xmlns:xsip="urn:hl7-org:v3"
>>The shema definition specifies: elementFormDefault="qualified"
>>(attributeFormDefault is not specified, and should there for default
>>to "unqualified" )
>>
>>When I print my xml file with : System.out.println(message.xmlText());
>>It then shows these settings for elementFormDefault and
>>attributeFormDefault in the use of the namespace (see below).
>>
>><xsip:MCCI_MT000100HT02.Message type="Message" xmlns="urn:hl7-org:v3"
>>xmlns:xsip="urn:hl7-org:v3"
>>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> <xsip:id root="1.1.83" extension="PRPA_HN000203.22"/>
>> <xsip:creationTime value="20030130140405.1440-0800"/>
>> <xsip:versionCode code="V3PR1"/>
>> <xsip:interactionId extension="PRPA_HN000203"/>
>> <xsip:processingCode code="P"/>
>> <xsip:processingModeCode code="T"/>
>> <xsip:acceptAckCode code="AL"/>
>> <xsip:communicationFunctionRCV type="CommunicationFunction">
>> <xsip:typeCode code="RCV"/>
>> <xsip:deviceRCV type="Device" classCode="DEV"
>>determinerCode="INSTANCE">
>> <xsip:id root="1.1.88" extension="88"/>
>> <xsip:playedAgentRCV type="Role" classCode="AGNT">
>> <xsip:representedOrganizationRCV type="Organization"
>>classCode="ORG" determinerCode="INSTANCE">
>> <xsip:id root="1.1.88.88"/>
>> </xsip:representedOrganizationRCV>
>> </xsip:playedAgentRCV>
>> </xsip:deviceRCV>
>> </xsip:communicationFunctionRCV>
>> <xsip:communicationFunctionRSP type="CommunicationFunction">
>> <xsip:typeCode code="RSP"/>
>> <xsip:deviceRSP type="Device" classCode="DEV"
>>determinerCode="INSTANCE">
>> <xsip:id root="1.1.83" extension="83"/>
>> <xsip:playedAgentRSP type="Role" classCode="AGNT">
>> <xsip:representedOrganizationRSP type="Organization"
>>classCode="ORG" determinerCode="INSTANCE">
>> <xsip:id root="1.1.83.83"/>
>> </xsip:representedOrganizationRSP>
>> </xsip:playedAgentRSP>
>> </xsip:deviceRSP>
>> </xsip:communicationFunctionRSP>
>> <xsip:communicationFunctionSND type="CommunicationFunction">
>> <xsip:typeCode code="SND"/>
>> <xsip:deviceSND type="Device" classCode="DEV"
>>determinerCode="INSTANCE">
>> <xsip:id root="1.1.83" extension="83"/>
>> <xsip:playedAgentSND type="Role" classCode="AGNT">
>> <xsip:representedOrganizationSND type="Organization"
>>classCode="ORG" determinerCode="INSTANCE">
>> <xsip:id root="1.1.83.83"/>
>> </xsip:representedOrganizationSND>
>> </xsip:playedAgentSND>
>> </xsip:deviceSND>
>> </xsip:communicationFunctionSND>
>> <xsip:MCAI_MT000001HT02.ControlActEvent type="ControlAct"
>>classCode="CACT" moodCode="EVN">
>> <xsip:code code="PRPA_TE000203" codeSystemName="HTB Supplemental"/>
>> <xsip:subject type="ActRelationship" typeCode="SUBJ">
>> <xsip:PRPA_MT400001HT02.EncounterEvent type="PatientEncounter"
>>classCode="ENC" moodCode="EVN">
>> <xsip:id root="1.1.83.400" extension="8"/>
>> <xsip:code code="16239" codeSystemName="HL7"/>
>> <xsip:statusCode code="completed"/>
>> <xsip:effectiveTime>
>> <xsip:low value="20050101164530.1250-0800"/>
>> <xsip:high value="20050130140405.1440-0800"/>
>> </xsip:effectiveTime>
>> <xsip:dischargeDispositionCode code="FL22.01"
>>codeSystemName="NUBC-UB92"/>
>> <xsip:preAdmitTestInd value="true"/>
>> <xsip:subject type="Participation" typeCode="SBJ">
>> <xsip:Patient type="Patient" classCode="PAT">
>> <xsip:id root="1.1.83.300" extension="307"/>
>> <xsip:effectiveTime>
>> <xsip:low value="20050101"/>
>> </xsip:effectiveTime>
>> <xsip:Person type="Person" classCode="PSN"
>>determinerCode="INSTANCE">
>> <xsip:id root="1.1.83.100" extension="307"/>
>> <xsip:name use="">
>> <xsip:family partType="FAM">Cornelissen</xsip:family>
>> <xsip:given partType="GIV">Jan</xsip:given>
>> <xsip:given partType="GIV">L</xsip:given>
>> </xsip:name>
>> <xsip:administrativeGenderCode code="10174"
>>codeSystemName="HL7"/>
>> <xsip:birthTime value="191905031304-0800"/>
>> <xsip:addr use="H">
>> <xsip:country partType="CNT">CA</xsip:country>
>> <xsip:state partType="STA">B.C.</xsip:state>
>> <xsip:county partType="CPA">CPA</xsip:county>
>> <xsip:city partType="CTY">Missisauga</xsip:city>
>> <xsip:postalCode partType="ZIP">8M3C5V</xsip:postalCode>
>> <xsip:streetAddressLine partType="SAL">23592 Anywhere
>>Street</xsip:streetAddressLine>
>> <xsip:streetName partType="STR">Anywhere
>>Street</xsip:streetName>
>> <xsip:houseNumber partType="HNR">23592</xsip:houseNumber>
>> <xsip:additionalLocator partType="ADL">Suite
>>103</xsip:additionalLocator>
>> </xsip:addr>
>> </xsip:Person>
>> <xsip:Organization type="Organization" classCode="ORG"
>>determinerCode="INSTANCE">
>> <xsip:id root="1.1.83.83"/>
>> </xsip:Organization>
>> </xsip:Patient>
>> </xsip:subject>
>> <xsip:admitter type="Participation" typeCode="ADM">
>> <xsip:time>
>> <xsip:low value="20050130140405.1440-0800"/>
>> </xsip:time>
>> <xsip:EmploymentStaff type="Employee" classCode="EMP">
>> <xsip:id root="1.1.83.200" extension="52"/>
>> </xsip:EmploymentStaff>
>> </xsip:admitter>
>> <xsip:pertinentInformation4 type="ActRelationship"
>>typeCode="PERT">
>> <xsip:ObservationEventDx type="Observation" classCode="OBS"
>>moodCode="EVN">
>> <xsip:code code="16840" codeSystemName="HL7"/>
>> <xsip:statusCode code="active"/>
>> <xsip:effectiveTime>
>> <xsip:low value="20050130140405.1440-0800"/>
>> <xsip:high value="20050130140405.1440-0800"/>
>> </xsip:effectiveTime>
>> <xsip:confidentialityCode code="PSY"
>>codeSystemName="Confidentiality"/>
>> <xsip:independentInd value="false"/>
>> <xsip:value code="233604007" codeSystemName="SNOMED-CT"
>>xsi:type="CE"/>
>> </xsip:ObservationEventDx>
>> </xsip:pertinentInformation4>
>> </xsip:PRPA_MT400001HT02.EncounterEvent>
>> </xsip:subject>
>> </xsip:MCAI_MT000001HT02.ControlActEvent>
>></xsip:MCCI_MT000100HT02.Message>
>>
>>
>>
>>
>>Radu Preotiuc-Pietro wrote:
>>
>>
>>
>>>I am going to take a wild guess here: is it possible that this
>>>is caused by "elementFormDefault", i.e. by the lack of one of those
>>>in the Schema?
>>>
>>>Radu
>>>
>>> -----Original Message-----
>>> *From:* Peter-Paul Rang [mailto:[EMAIL PROTECTED]
>>> *Sent:* Monday, June 27, 2005 2:29 AM
>>> *To:* [email protected]
>>> *Cc:* rang >> Peter-Paul Rang
>>> *Subject:* Re: NullPointerException when reading the leaves of
>>> the XML data
>>>
>>> The "id" element is there : <id root="1.1.83"
>>> extension="PRPA_HN000203.22"/>
>>>
>>> See xml file below:
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <MCCI_MT000100HT02.Message xmlns="urn:hl7-org:v3" type="Message"
>>> xmlns:xsip="urn:hl7-org:v3"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>> <id root="1.1.83" extension="PRPA_HN000203.22"/>
>>> <creationTime value="20030130140405.1440-0800"/>
>>> <versionCode code="V3PR1"/>
>>> <interactionId extension="PRPA_HN000203"/>
>>> <processingCode code="P"/>
>>> <processingModeCode code="T"/>
>>> <acceptAckCode code="AL"/>
>>> <communicationFunctionRCV type="CommunicationFunction">
>>> <typeCode code="RCV"/>
>>> <deviceRCV type="Device" classCode="DEV"
>>> determinerCode="INSTANCE">
>>> <id root="1.1.88" extension="88"/>
>>> <playedAgentRCV type="Role" classCode="AGNT">
>>> <representedOrganizationRCV type="Organization"
>>> classCode="ORG" determinerCode="INSTANCE">
>>> <id root="1.1.88.88"/>
>>> </representedOrganizationRCV>
>>> </playedAgentRCV>
>>> </deviceRCV>
>>> </communicationFunctionRCV>
>>> <communicationFunctionRSP type="CommunicationFunction">
>>> <typeCode code="RSP"/>
>>> <deviceRSP type="Device" classCode="DEV"
>>> determinerCode="INSTANCE">
>>> <id root="1.1.83" extension="83"/>
>>> <playedAgentRSP type="Role" classCode="AGNT">
>>> <representedOrganizationRSP type="Organization"
>>> classCode="ORG" determinerCode="INSTANCE">
>>> <id root="1.1.83.83"/>
>>> </representedOrganizationRSP>
>>> </playedAgentRSP>
>>> </deviceRSP>
>>> </communicationFunctionRSP>
>>> <communicationFunctionSND type="CommunicationFunction">
>>> <typeCode code="SND"/>
>>> <deviceSND type="Device" classCode="DEV"
>>> determinerCode="INSTANCE">
>>> <id root="1.1.83" extension="83"/>
>>> <playedAgentSND type="Role" classCode="AGNT">
>>> <representedOrganizationSND type="Organization"
>>> classCode="ORG" determinerCode="INSTANCE">
>>> <id root="1.1.83.83"/>
>>> </representedOrganizationSND>
>>> </playedAgentSND>
>>> </deviceSND>
>>> </communicationFunctionSND>
>>> <MCAI_MT000001HT02.ControlActEvent type="ControlAct"
>>> classCode="CACT" moodCode="EVN">
>>> <code code="PRPA_TE000203" codeSystemName="HTB Supplemental"/>
>>> <subject type="ActRelationship" typeCode="SUBJ">
>>> <PRPA_MT400001HT02.EncounterEvent type="PatientEncounter"
>>> classCode="ENC" moodCode="EVN">
>>> <id root="1.1.83.400" extension="8"/>
>>> <code code="16239" codeSystemName="HL7"/>
>>> <statusCode code="completed"/>
>>> <effectiveTime>
>>> <low value="20050101164530.1250-0800"/>
>>> <high value="20050130140405.1440-0800"/>
>>> </effectiveTime>
>>> <dischargeDispositionCode code="FLseem 22.01"
>>> codeSystemName="NUBC-UB92"/>
>>> <preAdmitTestInd value="true"/>
>>> <subject type="Participation" typeCode="SBJ">
>>> <Patient type="Patient" classCode="PAT">
>>> <id root="1.1.83.300" extension="307"/>
>>> <effectiveTime>
>>> <low value="20050101"/>
>>> </effectiveTime>
>>> <Person type="Person" classCode="PSN"
>>> determinerCode="INSTANCE">
>>> <id root="1.1.83.100" extension="307" />
>>> <name use="">
>>> <family partType="FAM">Cornelissen</family>
>>> <given partType="GIV">Jan</given>
>>> <given partType="GIV">L</given>
>>> </name>
>>> <administrativeGenderCode code="10174"
>>> codeSystemName="HL7"/>
>>> <birthTime value="191905031304-0800"/>
>>> <addr use="H">
>>> <country partType="CNT">CA</country>
>>> <state partType="STA">B.C.</state>
>>> <county partType="CPA">CPA</county>
>>> <city partType="CTY">Missisauga</city>
>>> <postalCode partType="ZIP">8M3C5V</postalCode>
>>> <streetAddressLine partType="SAL">23592 Anywhere
>>> Street</streetAddressLine>
>>> <streetName partType="STR">Anywhere
>>> Street</streetName>
>>> <houseNumber partType="HNR">23592</houseNumber>
>>> <additionalLocator partType="ADL">Suite
>>> 103</additionalLocator>
>>> </addr>
>>> </Person>
>>> <Organization type="Organization" classCode="ORG"
>>> determinerCode="INSTANCE">
>>> <id root="1.1.83.83"/>
>>> </Organization>
>>> </Patient>
>>> </subject>
>>> <admitter type="Participation" typeCode="ADM">
>>> <time>
>>> <low value="20050130140405.1440-0800"/>
>>> </time>
>>> <EmploymentStaff type="Employee" classCode="EMP">
>>> <id root="1.1.83.200" extension="52"/>
>>> </EmploymentStaff>
>>> </admitter>
>>> <pertinentInformation4 type="ActRelationship"
>>> typeCode="PERT">
>>> <ObservationEventDx type="Observation" classCode="OBS"
>>> moodCode="EVN">
>>> <code code="16840" codeSystemName="HL7"/>
>>> <statusCode code="active"/>
>>> <effectiveTime>
>>> <low value="20050130140405.1440-0800"/>
>>> <high value="20050130140405.1440-0800"/>
>>> </effectiveTime>
>>> <confidentialityCode code="PSY"
>>> codeSystemName="Confidentiality"/>
>>> <independentInd value="false"/>
>>> <value code="233604007" codeSystemName="SNOMED-CT"
>>> xsi:type="CE"/>
>>> </ObservationEventDx>
>>> </pertinentInformation4>
>>> </PRPA_MT400001HT02.EncounterEvent>
>>> </subject>
>>> </MCAI_MT000001HT02.ControlActEvent>
>>> </MCCI_MT000100HT02.Message>
>>>
>>> Adrian Shum wrote:
>>>
>>>
>>>
>>>>it looks to me that, in the raw xml, you didn't have the "id" element
>>>>in "message"
>>>>
>>>>
>>>>-----Original Message-----
>>>>From: Peter-Paul Rang [mailto:[EMAIL PROTECTED]
>>>>Sent: Monday, June 27, 2005 4:39 PM
>>>>To: [email protected]
>>>>Cc: rang >> Peter-Paul Rang
>>>>Subject: NullPointerException when reading the leaves of the XML data
>>>>
>>>>
>>>>I'm getting a NullPointerException when reading the leaves of the XML data
>>>>
>>>>I can read the XML File correctly, I can walk through the XML structure
>>>>correctly, I can print it correctly.
>>>>
>>>> String file = "D:/Htb/Dev/message/EE07_xmlbean.xml";
>>>> File inputFile = new File(file);
>>>> try
>>>> {
>>>> MCCIMT000100HT02Message message =
>>>>MCCIMT000100HT02Message.Factory.parse(inputFile);
>>>> System.out.println(message.xmlText());
>>>>
>>>>However, when I want to retrieve specific values from the xml file, I
>>>>get a NullPointerException.
>>>>
>>>> String extension = (String)message.getId().getExtension();
>>>>
>>>>-->
>>>>java.lang.NullPointerException
>>>> at parser.TestMyXMLBean.doAll(TestMyXMLBean.java:42)
>>>> at parser.TestMyXMLBean.main(TestMyXMLBean.java:82)
>>>>Process exited with exit code 0.
>>>>
>>>>Any hints and tips are very much appreciated.
>>>>
>>>>Thanks,
>>>>
>>>>Peter-Paul
>>>>
>>>>
>>>>
>>>>
>>>>
>>> --
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> <!--[if !supportEmptyParas]--> <!--[endif]-->
>>>
>>>
>>>
>>> *Peter-Paul Rang
>>> *Development Specialist
>>> /Business Technology Solutions/
>>>
>>>
>>>
>>>
>>>
>>> Oracle Nederland BV/
>>> Consulting/
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Rijnzathe 6
>>> P.O. Box 147
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> phone
>>> fax
>>>
>>>
>>>
>>> +31 30 669 8248
>>> +31 30 669 9966
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> 3454 ZJ De Meern
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> [EMAIL PROTECTED]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> The Netherlands
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>>
>>>
>>>
>>> Voor meer informatie over onze diensten bezoek ons op internet
>>> <http://www.oracle.com/nl/>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> <!--[if !supportEmptyParas]--> <!--[endif]-->
>>>
>>>
>>>
>>--
>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>*Peter-Paul Rang
>>*Development Specialist
>>/Business Technology Solutions/
>>
>>
>>
>>
>>
>>Oracle Nederland BV/
>>Consulting/
>>
>>
>>
>>
>>
>>
>>
>>Rijnzathe 6
>>P.O. Box 147
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>phone
>>fax
>>
>>
>>
>>+31 30 669 8248
>>+31 30 669 9966
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>3454 ZJ De Meern
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>[EMAIL PROTECTED]
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>The Netherlands
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>
>>
>>
>>
>>Voor meer informatie over onze diensten bezoek ons op internet
>><http://www.oracle.com/nl/>
>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>
>>
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]