Issue Details (XML | Word | Printable)

Key: XMLBEANS-248
Type: Bug Bug
Status: Resolved Resolved
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Unassigned
Reporter: Mark Cohen
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XMLBeans

Cannot parse/validate xml-fragments that use default namespace

Created: 24/Feb/06 02:27 AM   Updated: 01/Nov/09 06:54 PM
Return to search
Component/s: XmlObject
Affects Version/s: Version 1
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Win2K, Java 1.4

Resolution Date: 01/Nov/09 06:54 PM


 Description  « Hide
I recently ran into a problem with XMLBeans 1.0.2 parsing and validating XmlObjects. Here's the scenario:

I have a simple XML schema which I then turned into XMLBeans using the org.apache.xmlbeans.impl.tool.XMLBean class. For the sake of discussion, the namespace for the schema is http://common.toolkit/bean, and the package for the generated beans is toolkit.common.bean.

Next, I want to convert an XML fragment to an XMLBean. (I know, ideally there wouldn't be XML fragments, but there's not much I can do about it for now.) If I have something like the following... (Please ignore any obvious syntax errors -- I'm re-typing this.)

<xml-fragment xmlns:bean="http://common.toolkit/bean">
   <bean:field1>value</bean:field1>
   <bean:field2>value</bean:field2>
</xml-fragment>

... and I run it through a parse and a validation...

MyClass myObject = MyClass.Factory.parse(xml);
myObject.validate();

... everything works fine. If, however, I use the following XML instead...

<xml-fragment xmlns="http://common.toolkit/bean">
   <field1>value</field1>
   <field2>value</field2>
</xml-fragment>

... the validation fails. The error is along the lines of:

Message: Expected element text-
field1@http://common.toolkit/bean instead of xml-fragment@http://common.toolkit/bean here
Location of invalid XML: [my XML fragment repeated here]

Thoughts/ideas? Thanks in advance!

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jacob Danner made changes - 01/Nov/09 06:54 PM
Field Original Value New Value
Resolution Cannot Reproduce [ 5 ]
Fix Version/s Version 1 [ 10444 ]
Status Open [ 1 ] Resolved [ 5 ]