You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Maciej Zywno <m....@gmail.com> on 2004/12/13 14:24:46 UTC

is it possible to set xmlbeans compiler options in the way that xml validation is turned off?

Hi,

I could not find any ant <xmlbean> settings to turn off validation. I
want to compile classes from xsd in such a way that there is no
validation done during parsing. Thanks for any suggestions.

Maciek Zywno

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: is it possible to set xmlbeans compiler options in the way that xml validation is turned off?

Posted by David Jencks <dj...@gluecode.com>.
Aha!  I don't know what kind of document to expect until after I parse  
it, so I have been using

XmlObject.Factory.parse(...)

This lets you read in a document with no validation, modify it  
extensively so it is valid (such as changing the namespace), and then  
set its expected type and validate it.  You might like to take a look  
at  
http://svn.apache.org/repos/asf/geronimo/trunk/modules/j2ee-schema/src/ 
java/org/apache/geronimo/schema/SchemaConversionUtils.java for a few  
examples of what you can do -- I don't claim these are the best way,  
but they work for me.

david jencks

On Dec 14, 2004, at 12:44 AM, Maciej Zywno wrote:

> Thanks,
>
> I got generate and compiled interfaces and factories by means of ant
> task: <xmlbean ...>
> Then in my code I have something like:
> PoweredAirMultiAvailabilityReplyDocument doc =
> PoweredAirMultiAvailabilityReplyDocument.Factory
>                         .parse(new StringReader(response));
>
> and I get the following error:
> org.apache.xmlbeans.XmlException: error: The document is not a
> PoweredAir_MultiAvailabilityReply@http://www.amadeus.net: document
> element namespace mismatch expected "http://www.amadeus.net" got "".
>
> So as I guess I have to turn off the validation of the xml to be
> parsed. I guess I have to do it during the generation of  xmlbeans
> factories. Am I right?
>
> Regards,
> Maciek Zywno
>
> On Mon, 13 Dec 2004 14:16:47 -0800, David Jencks  
> <da...@yahoo.com> wrote:
>> I'm not sure what you are asking for.  My experience, which I believe
>> aligns with the documentation, is that parsing does no validation
>> beyond the ability to get SAX events and that validation against the
>> schema occurs only when you call validate on an XmlObject.
>>
>> thanks
>> david jencks
>>
>>
>>
>> On Dec 13, 2004, at 5:24 AM, Maciej Zywno wrote:
>>
>>> Hi,
>>>
>>> I could not find any ant <xmlbean> settings to turn off validation. I
>>> want to compile classes from xsd in such a way that there is no
>>> validation done during parsing. Thanks for any suggestions.
>>>
>>> Maciek Zywno
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: is it possible to set xmlbeans compiler options in the way that xml validation is turned off?

Posted by Maciej Zywno <m....@gmail.com>.
Actually I've been adding manually the namespace to my incoming XML
doc as a workaround, but I don't find quite an elegant solution. How
could I not find XmlOptions.setLoadSubstituteNamespaces! I've beed
loking at XMLOptions class for some time, poor me.. :)

Thanks!
Maciek Zywno


On Tue, 14 Dec 2004 10:55:45 +0000, Dave Harrison <da...@stacker.me.uk> wrote:
> Maciej,
> 
> It would seem your incoming doc doesn't include the namespace information.
> You need to either add the namespace to your incoming XML doc:
> 
> <PoweredAirMultiAvailabilityReply xmlns="http://www.amadeus.net">...
> 
> or use XmlOptions at parse time time map the empty/default namespace to
> http://www.amadeus.net:
> 
> XmlOptions opts = new XmlOptions.
> 
> Map namespaces = new HashMap();
> 
> namespaces.put("", "http://www.amadeus.net");
> 
> opts.setLoadSubstituteNamespaces(namespaces);
> 
> PoweredAirMultiAvailabilityReplyDocument doc = PoweredAirMultiAvailabilityReplyDocument.Factory.parse(response, opts);
> 
> Hope that helps.
> 
> DaveH.
> 
> 
> Maciej Zywno wrote:
> 
> >Thanks,
> >
> >I got generate and compiled interfaces and factories by means of ant
> >task: <xmlbean ...>
> >Then in my code I have something like:
> >PoweredAirMultiAvailabilityReplyDocument doc =
> >PoweredAirMultiAvailabilityReplyDocument.Factory
> >                        .parse(new StringReader(response));
> >
> >and I get the following error:
> >org.apache.xmlbeans.XmlException: error: The document is not a
> >PoweredAir_MultiAvailabilityReply@http://www.amadeus.net: document
> >element namespace mismatch expected "http://www.amadeus.net" got "".
> >
> >So as I guess I have to turn off the validation of the xml to be
> >parsed. I guess I have to do it during the generation of  xmlbeans
> >factories. Am I right?
> >
> >Regards,
> >Maciek Zywno
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: is it possible to set xmlbeans compiler options in the way that xml validation is turned off?

Posted by Dave Harrison <da...@stacker.me.uk>.
Maciej,

It would seem your incoming doc doesn't include the namespace information.
You need to either add the namespace to your incoming XML doc:

<PoweredAirMultiAvailabilityReply xmlns="http://www.amadeus.net">...

or use XmlOptions at parse time time map the empty/default namespace to 
http://www.amadeus.net:

XmlOptions opts = new XmlOptions.

Map namespaces = new HashMap();

namespaces.put("", "http://www.amadeus.net");

opts.setLoadSubstituteNamespaces(namespaces);

PoweredAirMultiAvailabilityReplyDocument doc = PoweredAirMultiAvailabilityReplyDocument.Factory.parse(response, opts);


Hope that helps.

DaveH.


Maciej Zywno wrote:

>Thanks,
>
>I got generate and compiled interfaces and factories by means of ant
>task: <xmlbean ...>
>Then in my code I have something like:
>PoweredAirMultiAvailabilityReplyDocument doc =
>PoweredAirMultiAvailabilityReplyDocument.Factory
>                        .parse(new StringReader(response));
>
>and I get the following error:
>org.apache.xmlbeans.XmlException: error: The document is not a
>PoweredAir_MultiAvailabilityReply@http://www.amadeus.net: document
>element namespace mismatch expected "http://www.amadeus.net" got "".
>
>So as I guess I have to turn off the validation of the xml to be
>parsed. I guess I have to do it during the generation of  xmlbeans
>factories. Am I right?
>
>Regards,
>Maciek Zywno
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: is it possible to set xmlbeans compiler options in the way that xml validation is turned off?

Posted by Maciej Zywno <m....@gmail.com>.
Thanks,

I got generate and compiled interfaces and factories by means of ant
task: <xmlbean ...>
Then in my code I have something like:
PoweredAirMultiAvailabilityReplyDocument doc =
PoweredAirMultiAvailabilityReplyDocument.Factory
                        .parse(new StringReader(response));

and I get the following error:
org.apache.xmlbeans.XmlException: error: The document is not a
PoweredAir_MultiAvailabilityReply@http://www.amadeus.net: document
element namespace mismatch expected "http://www.amadeus.net" got "".

So as I guess I have to turn off the validation of the xml to be
parsed. I guess I have to do it during the generation of  xmlbeans
factories. Am I right?

Regards,
Maciek Zywno

On Mon, 13 Dec 2004 14:16:47 -0800, David Jencks <da...@yahoo.com> wrote:
> I'm not sure what you are asking for.  My experience, which I believe
> aligns with the documentation, is that parsing does no validation
> beyond the ability to get SAX events and that validation against the
> schema occurs only when you call validate on an XmlObject.
> 
> thanks
> david jencks
> 
> 
> 
> On Dec 13, 2004, at 5:24 AM, Maciej Zywno wrote:
> 
> > Hi,
> >
> > I could not find any ant <xmlbean> settings to turn off validation. I
> > want to compile classes from xsd in such a way that there is no
> > validation done during parsing. Thanks for any suggestions.
> >
> > Maciek Zywno
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: is it possible to set xmlbeans compiler options in the way that xml validation is turned off?

Posted by David Jencks <da...@yahoo.com>.
I'm not sure what you are asking for.  My experience, which I believe 
aligns with the documentation, is that parsing does no validation 
beyond the ability to get SAX events and that validation against the 
schema occurs only when you call validate on an XmlObject.

thanks
david jencks

On Dec 13, 2004, at 5:24 AM, Maciej Zywno wrote:

> Hi,
>
> I could not find any ant <xmlbean> settings to turn off validation. I
> want to compile classes from xsd in such a way that there is no
> validation done during parsing. Thanks for any suggestions.
>
> Maciek Zywno
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org