Information Technology Reference
In-Depth Information
to extract all the documentation from any XML schema document and this can be
performed with the following Xquery:
declare variable dataDescription external;
declare function local:output($element,$counter)
{
<documentation
nodeType
=
"{node-name($element)}"
type
=
"{data($element/@type)}"
name
=
"{data($element/@name)}"
>{data($element/annotation/documentation/)}
</documentation>
};
declare function local:walk($node,$counter)
{
for $element in $node
where node-name($element)
=
"element" or node-name
($element)
=
"complexType"ornode-name($element)
=
"schema"
return
local:output($element,$counter)
};
declare function local:process-node($element,$counter)
{
for $subElement in $element where $counter < 3
return
if(node-name($subElement)
=
"element" or node-
name($subElement)
=
"complexType" or node-
name($subElement)
=
"schema") then
<node nodeType
=
"{node-name($subElement)}">
{
local:walk($subElement,$counter+1)
}