将带有导入名称空间的XSD架构上载到Marklogic 6
作为一个小练习,我尝试用几个模式上传和验证文档。它们最终会长大,所以我想把它们分开 这些示例模式定义了本地化文本字符串和食物盘: bitfood-common.xsd:将带有导入名称空间的XSD架构上载到Marklogic 6,xsd,marklogic,Xsd,Marklogic,作为一个小练习,我尝试用几个模式上传和验证文档。它们最终会长大,所以我想把它们分开 这些示例模式定义了本地化文本字符串和食物盘: bitfood-common.xsd: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:bfc="http://bitfood.org/common" targetNamespace="ht
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bfc="http://bitfood.org/common"
targetNamespace="http://bitfood.org/common"
elementFormDefault="qualified">
<xs:simpleType name="objectId">
<xs:restriction base="xs:string">
<xs:length value="24"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="locale">
<xs:restriction base="xs:string">
<xs:length value="5"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="localizedText">
<xs:attribute name="text" type="xs:string" use="required"/>
<xs:attribute name="locale" type="bfc:locale" use="required"/>
</xs:complexType>
</xs:schema>
然后我上传了一个示例文档:
dish/520cc720c208c01ddfb75254.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Dish id="520cc720c208c01ddfb75254" price="35"
imageUrl="FoodCantonGourrmetTwoDish.jpg"
xmlns="http://bitfood.org/dish">
<name text="Example dish." locale="en-US"/>
<description text="Localized text test." locale="en-US"/>
</Dish>
输出:
<?xml version="1.0" encoding="UTF-8"?>
<results warning="atomic item">xs:untypedAtomic("")</results>
谢谢 XQuery位置谓词从1开始,而不是从0开始。 试试这个: doc('dish/520cc720c208c01ddfb75254.xml')/bfd:dish[1] 然后逐步编写更复杂的代码
-李大卫啊。我的错:P。我想我也应该睡8个小时,呵呵。谢谢。遗憾的是,将索引更改为1会产生稍微不同的结果:((注意空字符串)xs:untypedAtomic(“”)Nevermind。访问索引1确实解决了问题。我很抱歉。
<?xml version="1.0" encoding="UTF-8"?>
<Dish id="520cc720c208c01ddfb75254" price="35"
imageUrl="FoodCantonGourrmetTwoDish.jpg"
xmlns="http://bitfood.org/dish">
<name text="Example dish." locale="en-US"/>
<description text="Localized text test." locale="en-US"/>
</Dish>
(: is it working? :)
declare namespace bfd = "http://bitfood.org/dish";
declare namespace bfc = "http://bitfood.org/common";
xdmp:describe(data(
doc('dish/520cc720c208c01ddfb75254.xml')/bfd:Dish[1]
))
<?xml version="1.0" encoding="UTF-8"?>
<results warning="atomic item">xs:untypedAtomic("")</results>
(: is it working? :)
declare namespace bfd = "http://bitfood.org/dish";
declare namespace bfc = "http://bitfood.org/common";
xdmp:describe(data(doc('dish/520cc720c208c01ddfb75254.xml')/bfd:Dish[1]/@id))