Hi Folks,

 

I'm trying to take an XML document that refers to a DTD and to remove the
DTD declaration and insert a default namespace.  I built a recursive
function that goes thru each node:

 

declare namespace pre = "http://mystuff.com/pre";;

 

declare function pre:passthru-nodeset($x as node()) as node()*
{
    for $z in $x/(@* | node()) return pre:build-nodeset($z)
};



declare function pre:build-nodeset($x as node()) as node()*
{
(:Revise link counts, clean up link, add link attributes to mixed-citation:)
    typeswitch ($x)
    case text() return $x
    case attribute () return $x
    case element (record)
        return 
            element record {        
            attribute xsi:schemaLocation { "/the-schema.xsd" },
            attribute xmlns:xsi
{"http://www.w3.org/2001/XMLSchema-instance"},
            attribute xmlns {"http://mystuff.com/schema"},
            pre:passthru-nodeset($x)}
    case element ()
        return element {string(local-name($x))} {
            pre:passthru-nodeset($x)}
    default return pre:passthru-nodeset($x)
};



The problem is that the resulting XML document from invoking
pre:build-nodeset($record) looks something like this:

 

<record xsi:schemaLocation="/APAthe-schema.xsd" id="1001" 

    xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

    xmlns="http://mystuff.com/schema";>
  <list xmlns="">
    <item>
       ...

 

and when I try to validate the resulting document a validation error occurs
because the default namespace has been renamed at the <list> element.  How
can I remove the xmlns="" declaration from the <list> element?

 

Thanks ahead of time,

 

Tim Meagher

_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to