我想规范化 XSD 输入文件以放在xs:
任何 XSD 元素之前而不用xs:
XQuery 前置。
copy $c:=doc("test.xsd")
modify
(
if($c/schema)
then
(
for $item in $c//*
where substring($item/text(), 1, 3) != "xs:"
return rename node $item as concat("xs:", $item/text())
)
else ()
)
return $c
在没有前置的输入 XSD 上运行此 xqy 会xs:
返回未更改的输入文件。我确实更新$c
并返回它。那么有什么问题呢?
输入文件:
<?xml version="1.0"?>
<schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<element name="note" type="xs:string"/>
</schema>
预期输出:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note" type="xs:string"/>
</xs:schema>
PS:看来我的问题引起了混乱。我需要xs:
出席,因为我有另一个文本处理程序,它只处理带xs:
前缀的元素。