|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
[jira] Created: (XMLBEANS-248) Cannot parse/validate xml-fragments that use default namespaceCannot parse/validate xml-fragments that use default namespace
-------------------------------------------------------------- Key: XMLBEANS-248 URL: http://issues.apache.org/jira/browse/XMLBEANS-248 Project: XMLBeans Type: Bug Components: XmlObject Versions: Version 1 Environment: Win2K, Java 1.4 Reporter: Mark Cohen Fix For: Version 1 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! -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: [jira] Created: (XMLBEANS-248) Cannot parse/validate xml-fragments that use default namespaceThe problem is that namespace qualifications are scoped for the
element as well as its contents. When you specify the default namespace in your second example, you're putting the xml-fragment into the http://common.toolkit/bean namespace. In other words, your second example is really equivalent to: > <bean:xml-fragment xmlns:bean="http://common.toolkit/bean"> > <bean:field1>value</bean:field1> > <bean:field2>value</bean:field2> > </bean:xml-fragment> How are you going to get a workaround? I'm not sure. It would be easier for you if the contents of the xml-fragment was a single element, then you could just apply your namespace there instead. One thing you could try is creating an XmlOptions object and using one of the synthetic element or namespace substitution tricks and passing it along to parse (i.e. figure out how to swap in a non-qualified xml-fragment qname for your namespace-qualified xml-fragment qname). Cheers, Ed On 2/23/06, Mark Cohen (JIRA) <xmlbeans-dev@...> wrote: > Cannot parse/validate xml-fragments that use default namespace > -------------------------------------------------------------- > > Key: XMLBEANS-248 > URL: http://issues.apache.org/jira/browse/XMLBEANS-248 > Project: XMLBeans > Type: Bug > Components: XmlObject > Versions: Version 1 > Environment: Win2K, Java 1.4 > Reporter: Mark Cohen > Fix For: Version 1 > > > 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! > > -- > This message is automatically generated by JIRA. > - > If you think it was sent incorrectly contact one of the administrators: > http://issues.apache.org/jira/secure/Administrators.jspa > - > For more information on JIRA, see: > http://www.atlassian.com/software/jira > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@... > For additional commands, e-mail: dev-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
[jira] Resolved: (XMLBEANS-248) Cannot parse/validate xml-fragments that use default namespace[ https://issues.apache.org/jira/browse/XMLBEANS-248?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jacob Danner resolved XMLBEANS-248. ----------------------------------- Resolution: Cannot Reproduce Fix Version/s: (was: Version 1) I tried to create a sample repro case for this using the latest XMLBeans and could not get any such error to repro. Given date, suggesting close. > Cannot parse/validate xml-fragments that use default namespace > -------------------------------------------------------------- > > Key: XMLBEANS-248 > URL: https://issues.apache.org/jira/browse/XMLBEANS-248 > Project: XMLBeans > Issue Type: Bug > Components: XmlObject > Affects Versions: Version 1 > Environment: Win2K, Java 1.4 > Reporter: Mark Cohen > > 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! -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
| Free embeddable forum powered by Nabble | Forum Help |