Hi,

 

I ran into that same issue with XmlSchema version 1.3.1 downloaded on May
31, 2007.

 

I can work around the issue by modifying XmlSchemaSerializer's method
appendElement method:

 

    private void appendElement(Document doc, Element parent,

                               Node children, XmlSchema schema) {

        Element elTmp = (Element) children;

    //  ---- OLD CODE

    //  Element el = createNewElement(doc, elTmp.getLocalName(),

    //          schema.schema_ns_prefix, XmlSchema.SCHEMA_NS);

    // ----- NEW CODE

        String ns = elTmp.getNamespaceURI();

        String pfx = schema.getNamespaceContext().getPrefix(ns);

        Element el = createNewElement(doc, elTmp.getLocalName(),

                pfx, ns);

        parent.appendChild(el);

    // ------ END MOD

        NamedNodeMap attributes = el.getAttributes();

 

It seems 2 things are missing:

- The markup is not supposed to be in the standard XML schema namespace but
rather belong to its own namespace.

- The result DOM element should be added as a child to the appInfo element.

 

For the new code to work, the markup namespace must be added to the schema
prefix list. I couldn't figure out an elegant way to add a namespace so my
code looks like this:

 

            /* Add a new namespace and prefix */

            NamespaceMap prefixmap = new NamespaceMap();

            NamespacePrefixList npl = schema.getNamespaceContext();

            for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {

                        prefixmap.add(npl.getDeclaredPrefixes()[i],
npl.getNamespaceURI(npl.getDeclaredPrefixes()[i]));

            }

            prefixmap.add("n0", NEW_NS);

            schema.setNamespaceContext(prefixmap);

 

Hope this helps fix the issue (if not already fixed).

 

Thanks

 

Fady

 

 

Reply via email to