0
我有以下XSD:我们可以提供XSD属性元数据吗?
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.w3schools.com"
xmlns="https://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="rootNode" type="records" />
<xs:complexType name="records">
<xs:sequence>
<xs:element name="element1" type="type-attrbute-grp" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="type-attrbute-grp">
<xs:attributeGroup ref="attribute-grp" />
</xs:complexType>
<xs:attributeGroup name="attribute-grp">
<xs:attribute name="scale" type="xs:int" use="required" />
<xs:attribute name="date" type="xs:date" use="required" />
</xs:attributeGroup>
</xs:schema>
而且我在下面创建XML:
<?xml version="1.0" encoding="UTF-8"?>
<p:rootNode xmlns:p="https://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.w3schools.com test2.xsd ">
<p:element1 date="2001-01-01" scale="7"/>
</p:rootNode>
我们可以提供关于与属性的元素的详细信息。但是,我的问题是我们能否提供关于属性的元数据? 我的目标是在UI中将“element1”显示为表格行,将“date”/“scale”显示为表格中的列。另外,我想为缩放和日期列添加一些验证,以及我想在XSD中提供的信息。即什么验证器应该适用于缩放以及我想在缩放单元格上显示哪个小部件?
谢谢Sprotty !!我尝试了2个解析器,一个来自“membrane-soa.org”,它没有正确解析注释,第二个来自“http://ws.apache.org/xmlschema/xmlschema-core/”,但它有点复杂。你知道除了jaxb以外的其他解析器吗? –
Xerces有一个模型(https://xerces.apache.org/xerces2-j/javadocs/xs/org/apache/xerces/xs/XSModel.html),它是一个非常薄的层,可以覆盖实际的XML数据记得。 JABX是一个XML数据绑定器(还有其他一些),您可以自定义它以获取appInfo数据并对其执行操作。这取决于你试图达到的目标,以及你是否希望自己编写代码或希望得到一个开箱即用的解决方案。 – Sprotty