Xml XQuery:计算元素构造函数是否没有结束标记?
使用下面的这个xqy文件,我只能生成一个开始的rdf:rdf标记。计算元素构造函数不应该为其生成结束标记吗 xqy文件:Xml XQuery:计算元素构造函数是否没有结束标记?,xml,xquery,Xml,Xquery,使用下面的这个xqy文件,我只能生成一个开始的rdf:rdf标记。计算元素构造函数不应该为其生成结束标记吗 xqy文件: declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; declare namespace owl="http://www.w3.org/2002/07/owl#"; declare namespace xsd="http://www.w3.org/2001/XMLSchema#"; decla
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
declare namespace owl="http://www.w3.org/2002/07/owl#";
declare namespace xsd="http://www.w3.org/2001/XMLSchema#";
declare namespace rdfs="http://www.w3.org/2000/01/rdf-schema#";
(:let $sourceDoc := "test.xsd":)
element {xs:QName("rdf:RDF")}
{
namespace {""} {"http://www.w3.org/2002/07/owl#"},
namespace {"owl"} {"http://www.w3.org/2002/07/owl#"},
namespace {"xsd"} {"http://www.w3.org/2001/XMLSchema#"},
namespace {"rdfs"} {"http://www.w3.org/2000/01/rdf-schema#"},
attribute xml:base {"http://www.w3.org/2002/07/owl"}
}
使用zorba的输出:
$ zorba -i -f -q test.xqy
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2002/07/owl"
xmlns:owl="http://www.w3.org/2002/07/owl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema"
xml:base="http://www.w3.org/2002/07/owl"/>
$zorba-i-f-q test.xqy
在本教程中,对
元素的每次调用都会生成一对标记。我自己找到了答案:
我应该在元素中添加新元素,如下所示:
declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
declare namespace owl="http://www.w3.org/2002/07/owl#";
declare namespace xsd="http://www.w3.org/2001/XMLSchema#";
declare namespace rdfs="http://www.w3.org/2000/01/rdf-schema#";
(:let $sourceDoc := "test.xsd":)
element {xs:QName("rdf:RDF")}
{
namespace {""} {"http://www.w3.org/2002/07/owl#"},
namespace {"owl"} {"http://www.w3.org/2002/07/owl#"},
namespace {"xsd"} {"http://www.w3.org/2001/XMLSchema#"},
namespace {"rdfs"} {"http://www.w3.org/2000/01/rdf-schema#"},
attribute xml:base {"http://www.w3.org/2002/07/owl"},
{
for $x in doc("test.xsd")/xs:schema/xs:element
return $x
}
}
xqy文件应反映输出文件的相同结构。然后,输出包含结束rdf标记:
$ zorba -i -f -q test.xqy
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2002/07/owl"
xmlns:owl="http://www.w3.org/2002/07/owl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema"
xml:base="http://www.w3.org/2002/07/owl">
<xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="contacts">
<xs:complexType>
<xs:sequence>
<xs:element ref="contact"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="contact">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:NCName"/>
<xs:element name="lastname" type="xs:NCName"/>
</xs:sequence>
<xs:attribute name="citizen" type="xs:string"/>
</xs:complexType>
</xs:element>
</rdf:RDF>
$zorba-i-f-q test.xqy
+1回答您自己的问题。你也可以接受你的答案。这给了其他人一个迹象,表明这个问题已经得到了可接受的回答。