|
Hi, I am new to XmlBeans. I like what I see so far. I
am having a problem getting XmlBeans to return the actual type (ServerType) for
my XPath query. What I get is XmlObject. Obviously, I am making
some mistake. But what is it? Please help J J 1. My Code: String queryExpression = "declare namespace iw='http://www.rao.com/iwf/xml-config';"
+ "./iw:iwf/iw:Server"; XmlOptions xopt = new XmlOptions(); xopt.setSaveOuter(); xopt.setSaveUseOpenFrag(); xopt.setUseDefaultNamespace(); XmlObject[] xo = idoc.selectPath(queryExpression, xopt); System.out.println(xo.getClass().getName()); System.out.println(xo[0].toString()); 2. Output: When querying for the IW:IWF elements, the output is [Lcom.rao.iwf.xmlConfig.IwfType; <xml-fragment
xsi:schemaLocation="http://www.dbs.com/iwf/xml-config
IwfConfigXml.xsd" xmlns:iw="http://www.dbs.com/iwf/xml-config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"> …. More lines deleted … When querying for the IW:IWF / IW:Server elements, the
output is [Lorg.apache.xmlbeans.XmlObject; <xml-fragment id="datadb"
provider="oracle-db" host="localhost" port="1521"
instance="ora92" user-id="swpro" password="swpro"
xmlns:iw="http://www.dbs.com/iwf/xml-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"/> Notice that the ClassName is XmlObject and not ServerType
(which I expect). 3. XSD <?xml version = "1.0" encoding = "UTF-8"?> <xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.rao.com/iwf/xml-config"
xmlns:iwf="http://www.rao.com/iwf/xml-config"> <xsd:element name="iwf" type="iwf:IwfType" /> <xsd:complexType name="IwfType"> <xsd:sequence> <xsd:element name="Server" type="iwf:ServerType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ServerType">
<xsd:attribute name="id"
type="xsd:string"
/>
<xsd:attribute name="provider" type="xsd:string" /> </xsd:complexType> </xsd:schema> 4. XML <?xml version="1.0" encoding="UTF-8"?> <iw:iwf xmlns:iw="http://www.dbs.com/iwf/xml-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:schemaLocation="http://www.dbs.com/iwf/xml-config
IwfConfigXml.xsd"> <!-- SERVERS --> <iw:Server id="datadb" provider="oracle-db"/> </iw:iwf> Best Regards Rao (Peruri Rama Mohan Rao) CONFIDENTIAL NOTE: The information contained in this email is intended only for the use of the individual or entity named above and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete the mail. Thank you. |
- XPath returns XMLObject instead of the actual Type Rama Mohan Rao Peruri
- RE: XPath returns XMLObject instead of the actu... Radu Preotiuc-Pietro
- RE: XPath returns XMLObject instead of the actu... Rama Mohan Rao Peruri

