Lawrence (et al) YOU DAH MAN! Exactly the problem and I have my problem fixed. Also the XPATH, XQUERY elements handle the qualification of attributes properly, eg mrm:attribute_name versus attribute_name work equally well. In addition, the XmlCursor and XmlObject interfaces will allow me to set the qualified names for attributes, or not.
I am impressed by XmlBeans, the quality of the documentation, and the fact that you seem to neither sleep, nor miss a detail. Thanks for the entire experience! John Dugaw Denver, CO ----- Original Message ----- From: Lawrence Jones [mailto:[EMAIL PROTECTED] Sent: 1/31/2006 10:14:16 AM To: [email protected] Subject: RE: Namespace Qualified Attributes? > Hi John > > Glad you found the previous post helpful (although note > elementFormDefault="qualified" attributeFormDefault="unqualified", while > definitely my favorite, is not required - it just maps to instance docs > that I find most readable). > > My suspicion with your problem is that you have all your attributes > declared globally (i.e. just inside the <schema> element). > elementFormDefault and attributeFormDefault affect only how _local_ > elements/attributes are referred to. Global elements/attributes must > always be referred to using the full namespace-qualified name. > > So if you want your attributes to not require a prefix I would use > attributeFormDefault="unqualified" (as you already do) _and_ I would > define my attributes locally i.e. within the definition of the element > on which you want them to appear. > > If that doesn't do it please post an example schema and instance doc and > I'll have a look at it. > > Not so sure on the XPath/XQuery issues. Am trying to find time to look > into those but not having much luck at the moment. Perhaps someone else > who already has experience using XPath/XQuery on XmlBeans could answer > for you? > > Cheers, > > Lawrence > > > -----Original Message----- > > From: John Dugaw [mailto:[EMAIL PROTECTED] > > Sent: Monday, January 30, 2006 8:55 PM > > To: [email protected] > > Subject: Namespace Qualified Attributes? > > > > All, > > > > I have run into a problem wherein I have forced the use of all tags in > an > > XML file to be namespace qualified, a desired effect. Unfortunately, > this > > also means that all my attributes also must be fully qualified. This > is > > not the behavior I expected, and I believe I have run into several > side > > effects. The information attached below I hope will be useful. > > > > The XSD: > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > > > > targetNamespace="http://www.unizenconsulting.com/MustReadMessages" > > xmlns="http://www.unizenconsulting.com/MustReadMessages" > > attributeFormDefault="unqualified" > > elementFormDefault="qualified"> > > > > I would expect this to give me an XMLBeans library that would require > > fully qualifed tags and unqualified attributes. Yet I am finding > myself > > needing to implement my XML files as in the following: > > > > <mrm:messageGroup > > xmlns:mrm="http://www.unizenconsulting.com/MustReadMessages" > > mrm:level="warn"> > > > > If I exclude the atrribute namespace qualifier I get validation errors > > about the "level" attribute not permitted. If I exclude it I get an > error > > about "level" being a required attribute. If I define it as > "mrm:level" > > then everything works, but I cannot get XPath and XQuery to work > properly > > (NOTE: I am using 8.1.1 per the docs at xmlbeans.apache.org) > > > > Unfortunately, when using the XmlCursor object trying to add the > attribute > > as in the following: > > > > String namespaceURI = cursor.namespaceForPrefix("mrm"); > > cursor.beginElement("message",namespaceURI); > > cursor.insertAttributeWithValue("level",level); > > > > This results in an error, and trying to use the following line: > > > > cursor.insertAttributeWithValue("mrm:level",level); > > > > also results in a runtime error. > > > > Now the results created when using the XMLBeans 2.0 generated classes > and > > API result in XML with the "mrm" namespace prefix to both the XML tags > and > > the attributes, effectively the same result I am required to provide > for > > things to work smoothly. > > > > I am also using an xsdconfig file but it basically maps the classes to > > com.unizenconsulting.mustReadMessages namespace within Java. > > > > POSSIBLE SIDE EFFECT: I am also having difficulty with Saxon XPATH and > > XQuery but firmly believe the namespace qualifiers to attributes is > the > > root cause e.g.: > > > > String query = "declare namespace " > > > > +"mrm='http://www.unizenconsulting.com/MustReadMessages'; " > > +" $this/mrm:messageGroup/mrm:message"; > > > > This strikes me as exceedingly odd. What have I missed? I am sure it > is > > something right in front of me. I did read the attribute comments from > > January '06 through September '06 which pointed me to my need for the > > 'elementFormDefault="qualified"' definition is the XSD itself before > using > > scomp. My thanks to Mr. Lawrence on that one! > > > > Regards, > > > > John Dugaw > > Denver, CO > > > > > > --------------------------------------------------------------------- > > 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]

