You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Butterwood, Richard" <Ri...@infor.com> on 2005/12/09 17:40:07 UTC
Attributes and NameSpaces
I can retrieve attributes using a XSD and XML without a name space, but
with a namespace the following will not work. I would appreciate any
help.
XSD (ResponseBatch.xsd)
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema targetNamespace="http://infor.com/ResponseBatch"
xmlns="http://infor.com/ResponseBatch"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="ResponseBatch">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CustomerNumber" type="xsd:string"/>
<xsd:element name="ValidCustomer" type="xsd:string"/>
<xsd:element name="CustomerName" type="xsd:string"/>
<xsd:element name="ListPrice" type="xsd:int"/>
</xsd:sequence>
<xsd:attribute ref="ResponseID"/>
<xsd:attribute ref="ConsumerKey"/>
<xsd:attribute ref="Language"/>
<xsd:attribute ref="DateTime"/>
<xsd:attribute ref="SerialID"/>
</xsd:complexType>
</xsd:element>
<xsd:attribute name="ResponseID" type="xsd:string"/>
<xsd:attribute name="ConsumerKey" type="xsd:string"/>
<xsd:attribute name="Language" type="xsd:string"/>
<xsd:attribute name="DateTime" type="xsd:string"/>
<xsd:attribute name="SerialID" type="xsd:string"/>
</xsd:schema>
XML (ResponseBatch.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!-- Contains weather details of a location.-->
<ResponseBatch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
ResponseID="ValidateCustomer" ConsumerKey="1234" Language="English"
DateTime="today" SerialID="001" xmlns="http://infor.com/ResponseBatch">
<CustomerNumber>C100</CustomerNumber>
<ValidCustomer>Y</ValidCustomer>
<CustomerName>Southeastern Industrial & Supp</CustomerName>
<ListPrice>3</ListPrice>
</ResponseBatch>
Java Test Code (ResponseBatch.java)
import com.infor.responseBatch.*;
// import noNamespace.*;
// Illustrates how to use XMLBeans classes to get weather
details from an
// xml document in weatherInput.xml file.
public class ResponseBatch {
public static void main(String args[]) {
try {
System.out.println("At the
start111");
String filePath =
"c:\\aa1\\ResponseBatch.xml";
java.io.File inputXMLFile = new
java.io.File(filePath);
ResponseBatchDocument
ResponseBatchDoc = ResponseBatchDocument.Factory
.parse(inputXMLFile);
ResponseBatchDocument.ResponseBatch
ResponseBatchElement = ResponseBatchDoc.getResponseBatch();
System.out.println("ValidateCustomer
details of Response ID "
+
ResponseBatchElement.getResponseID()
+ ", Consumer ID = "
+ ResponseBatchElement.getConsumerKey()
+ ",
Language = " + ResponseBatchElement.getLanguage()
+ ",
Date/Time = " + ResponseBatchElement.getDateTime()
+ ", Serial
ID = " + ResponseBatchElement.getSerialID());
/*
ResponseBatchDocument.ResponseBatch.Response ResponseElement =
ResponseBatchElement.getResponse();
System.out.println("Customer Number
is "+ ResponseElement.getCustomerNumber());
System.out.println("Customer Name is
" + ResponseElement.getCustomerName());
System.out.println("Valid Customer
is " + ResponseElement.getValidCustomer());
System.out.println("List Price is "
+ ResponseElement.getListPrice());
*/
} catch (Exception e) {
e.printStackTrace();
}
}
}
Richard Butterwood | Senior Analyst/Programmer | Infor | office:
770-418-2000 X 1167 | cell: 678-492-3080 | fax: 770-418-2022 |
richard.butterwood@infor.com
SAVE THE DATE:
Inforum
Infor Customer Conference
April 9 - 12, 2006
Mandalay Bay Resort & Casino
Las Vegas