Never mind. I finally decided that it was the use of the constant="..."
attribute that was killing JiBX. I gave in and changed the attribute
binding as follows:

<value name="noNamespaceSchemaLocation"
ns="http://www.w3.org/2001/XMLSchema-instance";
 field="schemaLocation" usage="optional"/>

and just added a String schemaLocation field into the Module class that
this attribute appears in. Works perfectly. 

This does suggest there may be a bug with the constant attribute of the
<value> element, however, unless I was just using it incorrectly.

-------------------------------------------------------------------
Dan Cooperstock, Senior Software Developer, Quest Software
260 King St. E., Toronto ON Canada  M5A 4L5
[EMAIL PROTECTED]    416-933-5165
 
With Quest Software, you can expect more ... more performance, more
productivity, more value from your IT investments.

Visit www.quest.com to learn how.


-----Original Message-----
From: Dan Cooperstock 
Sent: Wednesday, August 31, 2005 9:52 AM
To: '[email protected]'
Subject: Maintaining schema attributes

I have a XML file that is being both marshaled and unmarshaled by JiBX.
I want to add in attributes for the XML schema I use to validate it into
the root element of the XML, as follows:

<module version="0.1" display-name="Dan's Module"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 
xsi:noNamespaceSchemaLocation="../../../../../core/config/jibx/module.xs
d">
...
</module>

I'm not expecting JiBX to do anything with the schema, but I want to set
things up so that the two attributes related to the schema validation
(xmlns:xsi and xsi:noNamespaceSchemaLocation) don't get lost when the
document is unmarshalled and then marshalled again.

Having read the docs, here is my partial mapping that I think should do
it:

<binding name="module" value-style="attribute"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:noNamespaceSchemaLocation="binding.xsd">
    <namespace prefix="xsi"
uri="http://www.w3.org/2001/XMLSchema-instance"/>

    <mapping name="module" class="com.quest.wcf.core.module.Module"
        factory="com.quest.wcf.core.module.Module.createModule">
        <value name="noNamespaceSchemaLocation"
ns="http://www.w3.org/2001/XMLSchema-instance";
            constant="../../../../../core/config/jibx/module.xsd"/>
        ...

Unfortunately, this generates the following error:

Error running binding compiler

*** Error during code generation - please report this error on the JiBX
users list so that the condition can be caught during validation ***

java.lang.IllegalStateException: Internal error: Too few values on stack

 full stack:

        at
org.jibx.binding.classes.MethodBuilder.verifyStackDepth(MethodBuilder.ja
va:432)
        at
org.jibx.binding.classes.MethodBuilder.appendPOP(MethodBuilder.java:1341
)
        at
org.jibx.binding.def.ValueChild.genUnmarshal(ValueChild.java:503)
        ...

Any bright ideas? Thanks.

-------------------------------------------------------------------
Dan Cooperstock, Senior Software Developer, Quest Software 260 King St.
E., Toronto ON Canada  M5A 4L5
[EMAIL PROTECTED]    416-933-5165
 
With Quest Software, you can expect more ... more performance, more
productivity, more value from your IT investments.

Visit www.quest.com to learn how.



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to