Xml MarkLogic中的默认模式值
我正试图通过Xml MarkLogic中的默认模式值,xml,xsd,xquery,marklogic,Xml,Xsd,Xquery,Marklogic,我正试图通过xdmp:document-insert()插入一个文档,在调用该文档之前,我将通过validate strict{$xml}根据其各自的模式验证文档,并在插入调用中使用该输出。但是,validate调用的输出不包括架构中指定的默认值 简化模式: <xs:schema> <xs:complexType name="fields-type" abstract="false" mixed="false"> <xs:sequence minOccu
xdmp:document-insert()
插入一个文档,在调用该文档之前,我将通过validate strict{$xml}
根据其各自的模式验证文档,并在插入调用中使用该输出。但是,validate
调用的输出不包括架构中指定的默认值
简化模式:
<xs:schema>
<xs:complexType name="fields-type" abstract="false" mixed="false">
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element default="Faulkner" maxOccurs="1" minOccurs="0" name="an_author" nillable="false" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="document-type" abstract="false" mixed="false">
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="fields" type="fields-type" minOccurs="1" maxOccurs="1" nillable="false"/>
</xs:sequence>
</xs:complexType>
<xs:element name="document" type="document-type" abstract="false" nillable="false"/>
</xs:schema>
该文件:
<document>
<fields>
<an_author/>
</fields>
</document>
输出应该指定默认值。默认值实际上是数据模型的一部分,但在输出数据模型时,它们不一定序列化。通过对默认属性执行路径表达式,可以验证它们是否在数据模型中
如果要确保它们在输出时序列化,则有一个输出设置将强制它们发出:
declare option xdmp:output "default-attributes=yes";
(也可以在xdmp:quote
或xdmp:save
上设置选项默认属性)
或者,您可以强制复制数据模型实例,该实例将携带所有属性,但忘记它们是默认的:
let $d := validate strict { $node }
return document { $d }
我想你不明白我的问题。调用validate
后,模式中设置在xs:element
上的默认属性应使an_author
的值为Faulkner
。摘自XML模式规范“模式处理器为元素提供的值等于默认属性的值”。我认为她可能不理解您的问题,但在阅读了问题、答案和您的注释后,我觉得您更像是不理解答案。你试过这个建议了吗?您是否有一个示例显示,即使在声明选项xdmp:output“defaultattributes=yes”之后代码>序列化文档仍然没有默认值?在调用validate
后,是否使用路径表达式检查默认值是否实际显示在数据模型中?