Thanks David! This appears to be working for us.

- Dan

David Jencks wrote:

I had this problem in geronimo's SchemaInfoBuilder class when we extract schemas from wsdls and process the schemas using xmlbeans starting from a DOM element.

Here's my code:

static XmlObject parseWithNamespaces(Element element, Map namespaceMap) throws XmlException {
        ArrayList errors = new ArrayList();
XmlOptions xmlOptions = SchemaConversionUtils.createXmlOptions(errors); SchemaDocument parsed = SchemaDocument.Factory.parse(element, xmlOptions);
        if (errors.size() != 0) {
            throw new XmlException(errors.toArray().toString());
        }
        XmlCursor cursor = parsed.newCursor();
        try {
            cursor.toFirstContentToken();
for (Iterator namespaces = namespaceMap.entrySet().iterator(); namespaces.hasNext();) {
                Map.Entry entry = (Map.Entry) namespaces.next();
cursor.insertNamespace((String) entry.getKey(), (String) entry.getValue());
            }
        } finally {
            cursor.dispose();
        }
        return parsed;
    }


Hope this helps,
david jencks

On Sep 16, 2005, at 12:51 PM, Dan Diephouse wrote:

We're having an issue using XmlBeans to parse portions of a StAX stream. Take for instance a request like so:

<soapenv:Envelope
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <soapenv:Body>
<Foo xsi:type="xsd:string"xmlns="http://foo.com/bar";>T</RefNum>
          </Header>
      </Request>
  </soapenv:Body>

If we're using XmlBeans to only parse the Foo element, this causes an issue. When XmlBeans generates the document that represents Foo it doesn't pull the xsd namespace from Envelope (which makes sense). But XmlBeans doesn't want to parse the document unless there is that xsd declaration. An example exception:

org.apache.xmlbeans.XmlRuntimeException: error: cvc-elt.4.1: Invalid xsi:type qname: 'xsd:string' in element [EMAIL PROTECTED]://www.paraware.com/2005/ PriceAndAvailabilityCheckRequest at com.paraware.webservice.selfservice.PriceAndAvailabilityServiceImpl.che ckPriceAndAvailability(PriceAndAvailabilityServiceImpl.java:94)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Any ideas on solutions for this issue? If we saved the namespace declarations, is it possible to redeclare the namespaces somewhere before validation?

Thanks,

- Dan

---------------------------------------------------------------------
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to