我有一个 xsd 文件projectName/Resources/Schema.xsd(命名空间http://www.mycompany.com/SomeSchema)用于翻译,但需要动态设置元素名称。对于 Static 选项,我可以手动选择一个元素(顺便说一句,类型不显示),例如名为 someElement1,然后将 2 个元素添加到 nxsdTranslation 中:
<con3:nxsd ref="projectName/Resources/Schema"/>
<con3:schemaElement xmlns:ns="http://www.mycompany.com/SomeSchema">ns:someElement1</con3:schemaElement>
当我选择Dynamic并选择XQuery Expression时,我可以输入任何xquery元素表达式,但我没有找到任何信息,应该在那里指定什么。我尝试了几次猜测,但每次都收到错误
XML to Native nXSD translation failed for the nXSD : null
有人知道Dynamic nXSD Schema到底应该返回什么吗?
用于动态 NXSD 转换的 XQuery 类似于动态验证:
<translate xmlns="http://www.bea.com/wli/sb/context">
<schema>$schemaPath</schema>
<schemaElement>
<namespaceURI>$elementNamespace</namespaceURI>
<localname>$elementName</localname>
</schemaElement>
</translate>
其中 $schemaPath - xsd 文件的绝对路径,不带 .xsd 扩展名,例如 my-project/Resources/my-schema
$elementNamespace 和 $elementName - 元素命名空间和本地名称
xquery 根元素名称(即本例中的 translate)根本不重要