使用下面的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#";
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"/>
在this教程中,element
的每次调用都会生成一对标记。
答案 0 :(得分:2)
自己找到答案:
我应该在element
中添加新元素,如下所示:
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>