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]

Reply via email to