我有一个 XML,需要为其生成 XSD。我的 XML 如下:
实例:
<mes:GetInboundResponseGetInboundSMS
xmlns:mes="http://abcd.com">
<response>
<messages>
<item>
<date>15/04/2014 00:00:00</date>
</item>
<item>
<date>01/07/2014 10:01:32</date>
</item>
</messages>
</response>
</mes:GetInboundResponseGetInboundSMS>
Run Code Online (Sandbox Code Playgroud)
请注意,只有最外面的元素GetInboundResponseGetInboundSMS属于命名空间http://abcd.com- 其余元素不属于。如何在 XSD 中指定这一点?
我尝试过以下 XSD,但这给了我错误:
XSD:
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="GetInboundResponseGetInboundSMS">
<xs:complexType>
<xs:sequence>
<xs:element name="response">
<xs:complexType>
<xs:sequence>
<xs:element name="messages">
<xs:complexType>
<xs:sequence>
<xs:element name="item"
maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用在线验证器通过 XSD 验证实例时,我最终遇到了以下错误:
无效。
错误 - 第 1 行,第 95 …
这是我的示例 XML 代码:
<Address>
<StreetAddress></StreetAddress>
<OtherDestination />
<City>TORONTO</City>
</Address>
Run Code Online (Sandbox Code Playgroud)
目前正在使用这个 XSD:
<xs:element name="Address" nillable="true">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:element ref="StreetAddress" minOccurs="0"/>
<xs:element ref="OtherDestination" minOccurs="0"/>
<xs:element ref="City" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
我想id向Address这样的元素添加一个属性..
<Address id="first">
<StreetAddress></StreetAddress>
<OtherDestination />
<City>TORONTO</City>
</Address>
Run Code Online (Sandbox Code Playgroud)
我应该如何更改现有的 XSD 以满足我的要求?
我正在尝试使用以下模式通过 XSD 模式验证来验证 XML 元素,但它不起作用。所需的行为是允许除模式表达式中提到的字符之外的所有字符。
<xsd:pattern value="^[^><{}|^`\[\]\\\\]*$"/>
Valid data : TESTING
Invalid data : TE{ST]`I<NG
Run Code Online (Sandbox Code Playgroud)
但上面的模式也在 XSD 中给出了有效数据(测试)的验证错误,但如果我在 java 正则表达式匹配包中使用此模式,同样可以正常工作。请帮忙。
我正在尝试使用正则表达式来阅读我的文档以识别货币类型,无论它们是$,£还是a €.我创建的正则表达式似乎不起作用,有人请告诉我它应该是什么.我真的很感激帮助:
我创建的正则表达式("\$|£|€]")是在我的XSD文件中的simpleType中,用于验证文档.代码显示在冒号后面:
<xs:simpleType name="currencyType">
<xs:restriction base="utf8-string">
<xs:length value="1" />
<xs:pattern value="[\$|£|€]"/>
</xs:restriction>
</xs:simpleType>
Run Code Online (Sandbox Code Playgroud) 我是Mule的新手,但使用了其他有关集成的产品.
从文件入站端点接收XML后,我想针对XSD验证它.如果验证失败,我想将其发送到JMS/VM队列,否则只需继续我的其他已经工作的流程.
我已经能够使用过滤器,它按预期工作.那些不合规的人会被网络空间抛弃.但我想处理这些并返回响应.
那么我可以选择其他什么方法呢?
是否有可以使用验证的XML/XSD路由器?
谢谢.
我定义了一个xsd:
非常类似于HTML表.rows有列,列有元素.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:attributeGroup name="basics">
<xs:attribute name="title" type="xs:string" use="required"/>
<xs:attribute name="field_id" type="xs:string" use="required"/>
<xs:attribute name="is_mandatory" type="xs:boolean" use="required"/>
</xs:attributeGroup>
<xs:element name="form">
<xs:complexType>
<xs:sequence>
<xs:element name="row">
<xs:complexType>
<xs:sequence>
<xs:element name="col">
<xs:complexType>
<xs:sequence>
<!-- lable -->
<xs:element name="label" type="xs:string"/>
<!-- image -->
<xs:element name="image" >
<xs:complexType>
<xs:attribute name="src" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<!-- textbox -->
<xs:element name="textbox">
<xs:complexType>
<xs:attributeGroup ref="basics"/>
<xs:attribute name="hint" type="xs:string" use="optional" default=""/>
</xs:complexType>
</xs:element>
<!-- yesno -->
<xs:element name="yesno">
<xs:complexType>
<xs:attributeGroup ref="basics"/>
</xs:complexType>
</xs:element>
<!-- calendar -->
<xs:element name="calendar"> …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Web服务SOAP,我已经定义了我的xsd模式和wsdl文件,我想comment通过修复他的最大长度来验证元素(其类型是字符串).但是当我使用SoapUI验证请求时,在我看来xsd架构不会验证字符串最大长度.
以下是我的xsd架构的语法:
<xsd:element name="comment" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
Run Code Online (Sandbox Code Playgroud)
谁知道为什么?提前致谢.
XML Schema 中十进制类型的最小和最大可接受值是多少?( type="xs:decimal")?
我想设置minInclusive为0.01。我尝试过以下一种但失败了。
<xs:simpleType name="WeightType">
<xs:restriction base="xs:decimal">
<xs:totalDigits value="5"/>
<xs:fractionDigits value="2"/>
<xs:minInclusive value="0.01"/>
</xs:restriction>
</xs:simpleType>
Run Code Online (Sandbox Code Playgroud)
有人可以建议如何写吗?
如果不可能的话,还有其他方法可以实现吗?我的要求是字段应该大于0。
我对 XML 非常陌生,目前准备使用 Ineasysteps。我不断从解析器那里得到同样的问题
5:元素“xsd:schema”的前缀“xsd”未绑定。
这是 hello.xml:
<?xml version = "1.0" encoding = "UTF-8" ?>
<!-- XML in easy steps - Page 82. -->
<doc xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation = "hello.xsd" >
<msg>Hello World</msg>
</doc>
Run Code Online (Sandbox Code Playgroud)
这是 hello.xsd 文档
<?xml version="1.0" encoding = "UTF-8" ?>
<!-- XML in easy steps - Page 84. -->
<xsd:schema>
<!-- DECLARE ELEMENTS. -->
<!-- Simple types. -->
<xsd:element name="msg" type="xsd:string"/>
<!-- Complex types. -->
<xsd:element name="doc" type="docType"/>
<!-- DEFINE STRUCTURE. -->
<xsd:complexType name="docType">
<xsd:sequence>
<xsd:element ref="msg"/> …Run Code Online (Sandbox Code Playgroud)