I am trying to use XML beans in doing simple parsing and data retieval.
I successfully generated all the Java classes for two schemas. The parsing of
an XML document built with these two embedded XML from two different namespaces
seems to be working well. But, I can't retrieve the simple element values using
the get methods. I was able to do it for a simple XML from one
schema/namespace. Also, I noticed that it only works if you parse from the
document class ("Element"Document.Factory.parse()). And, it does not work if
you parse directly with the element class ("Element".Factory.parse()). I could
not find out why in the user guides?
thanks to help identify the simple thing I am not seeing!
Here are the details below:
I use Win2000 with latest XML Beans 2.
The following is my code snipet:
File msgFile = new File(reqMsgDocFilename);
EnvelopeDocument soapEnvDoc = EnvelopeDocument.Factory.parse(msgFile);
Envelope soapEnv = soapEnvDoc.getEnvelope();
Header soapHdr = soapEnv.getHeader();
HeaderT hdrT = HeaderT.Factory.parse(soapHdr.getDomNode());
System.out.println("\nRequest header fragment as Xbean toStr:\n"+hdrT.toString
());
System.out.println("hdrT.activity="+hdrT.getActivityName());
The following is the output from the above code:
Request header fragment as Xbean toStr:
<soap:Header xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns="tmf854.v1">
<header>
<activityName>getSNCsByUserLabel</activityName>
<msgName>getSNCsByUserLabel</msgName>
<msgType>REQUEST</msgType>
<replyToURI>MTOSI/CramerOS</replyToURI>
<correlationId>1234</correlationId>
<communicationPattern>SimpleResponse</communicationPattern>
<communicationStyle>MSG</communicationStyle>
<timestamp>20051004140259</timestamp>
</header>
</soap:Header>
hdrT.activity=null
Notice that I have two schemas 1:SOAP-ENV and 2:MyOwn (default namespace)
I can't get to any of the <header> element values (getActivityName returned
null)
Here is my own schema
<?xml version="1.0" encoding="UTF-8"?>
<!-- TMF854 Version 1.0 - Copyright TeleManagement Forum 2005 -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="tmf854.v1" xmlns="tmf854.v1"
attributeFormDefault="unqualified" elementFormDefault="qualified">
<!-- ======= All includes ======= -->
<xsd:include schemaLocation="headerVendorExtensions.xsd"/>
<!-- ======== Global Type Declarations ========= -->
<xsd:simpleType name="ActivityName_T">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\w*"/>
</xsd:restriction>
</xsd:simpleType>
...
<xsd:element name="header" type="Header_T"/>
<xsd:complexType name="Header_T">
<xsd:all>
<xsd:element name="activityName" type="ActivityName_T">
</xsd:element>
...
</xsd:complexType>
</xsd:schema>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]