从 XML 生成 XSD 并添加命名空间 XSLT
Generating XSD from XML and add namespace XSLT
我需要你的帮助 XML ---> XSD 代 + 添加命名空间。
我再解释一下。
XML
(这是代码,以防您想复制它以供回复...)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com"
xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<urn:update>
<urn:sObjects xsi:type="urn1:Account">
<urn1:Id>001b0000006mKKqAAM</urn1:Id>
<!--You may enter ANY elements at this point-->
<AnnualRevenue>9988</AnnualRevenue>
<Name>Farell Instruments WYNSYS</Name>
</urn:sObjects>
</urn:update>
</soapenv:Envelope>
XSD
(这是代码,以防您想复制它以供回复...)
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="urn:enterprise.soap.sforce.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="update">
<xs:complexType>
<xs:sequence>
<xs:element name="sObjects">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="Id"/>
<xs:element type="xs:string" name="Name"/>
</xs:sequence>
<xs:attribute type="xs:string" name="type"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
我现在的要求是像这样传递帐户类型的属性:
urn:sObjectsxsi:type="urn1:Account"
但使用 XSD,我认为我需要使用 XSD 映射才能做到这一点!
我完全迷失了我尝试了几种格式,但仍然没有找到正确的格式。
知道如何获得 XML 的准确 XSD 格式吗?
谢谢。
BR,
穆罕默德·阿明。
XSD 模式验证使用 xsi:type
属性的内置定义;无法在架构中指定它必须具有特定值或将其值限制在 XSD 规范强加的约束之外。
如果您正在尝试编写一个 XSD 架构来限制 xsi:type 的值,那么您现在可以停止尝试并寻找其他解决方案来解决您的问题。如果您不想这样做,那么您需要再次尝试解释您正在尝试做什么;从问题中不清楚。
我需要你的帮助 XML ---> XSD 代 + 添加命名空间。 我再解释一下。
XML (这是代码,以防您想复制它以供回复...)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com"
xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<urn:update>
<urn:sObjects xsi:type="urn1:Account">
<urn1:Id>001b0000006mKKqAAM</urn1:Id>
<!--You may enter ANY elements at this point-->
<AnnualRevenue>9988</AnnualRevenue>
<Name>Farell Instruments WYNSYS</Name>
</urn:sObjects>
</urn:update>
</soapenv:Envelope>
XSD (这是代码,以防您想复制它以供回复...)
<xs:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="urn:enterprise.soap.sforce.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="update">
<xs:complexType>
<xs:sequence>
<xs:element name="sObjects">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="Id"/>
<xs:element type="xs:string" name="Name"/>
</xs:sequence>
<xs:attribute type="xs:string" name="type"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
我现在的要求是像这样传递帐户类型的属性: urn:sObjectsxsi:type="urn1:Account"
但使用 XSD,我认为我需要使用 XSD 映射才能做到这一点! 我完全迷失了我尝试了几种格式,但仍然没有找到正确的格式。
知道如何获得 XML 的准确 XSD 格式吗?
谢谢。 BR, 穆罕默德·阿明。
XSD 模式验证使用 xsi:type
属性的内置定义;无法在架构中指定它必须具有特定值或将其值限制在 XSD 规范强加的约束之外。
如果您正在尝试编写一个 XSD 架构来限制 xsi:type 的值,那么您现在可以停止尝试并寻找其他解决方案来解决您的问题。如果您不想这样做,那么您需要再次尝试解释您正在尝试做什么;从问题中不清楚。