Hi Lawrence,
Thank you for the reply. Option 1 did not seem to work. Option 2 worked great!
Richard Butterwood | Senior Analyst/Programmer | Infor | office: 770-418-2000 X 1167 | cell: 678-492-3080 | fax: 770-418-2022 | [EMAIL PROTECTED] From: Lawrence Jones
[mailto:[EMAIL PROTECTED]
Hi Richard
I think you’re running into the infamous elementFormDefault=”qualified” | ”unqualified” issue.
If you don’t put an elementFormDefault attribute in the <schema> element of your schema the default is elementFormDefault=”unqualified”. This means that when you refer to non-global elements (such as your CustomerNumber, ValidCustomer … elements below) you _must_ refer to them _without_ a namespace. Global elements are unaffected by this setting – you must always refer to them with a namespace (if one was defined in the original schema).
On the other hand if you add the attribute elementFormDefault=”qualified” to the <schema> element then all elements (global and local) _must_ be referred to _with_ the namespace.
So you have 2 choices:
Personally I recommend option 1. But that’s just me – I’ve heard people argue it both ways.
Cheers,
Lawrence
From: Butterwood, Richard [mailto:[EMAIL PROTECTED]
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 | [EMAIL PROTECTED]
SAVE THE DATE:
|
- Attributes and NameSpaces Butterwood, Richard
- RE: Attributes and NameSpaces Lawrence Jones
- Re: Attributes and NameSpaces Samuel B. Quiring
- RE: Attributes and NameSpaces Butterwood, Richard
- RE: Attributes and NameSpaces Radu Preotiuc-Pietro
- RE: Attributes and NameSpaces Lawrence Jones