我有一个在我的 Xquery 请求中定义的表单。此表单建立在 XSD 架构上。
我的表格:
<xsd:element name="AddInsuranceToOrderForm">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="OrderId" type="xsd:long" minOccurs="1" maxOccurs="1"/>
<xsd:element name="DistributionChannel" type="xsd:long" minOccurs="1" maxOccurs="1"/>
<xsd:element name="FloatNumber" type="xsd:long" minOccurs="1" maxOccurs="1"/>
<xsd:element name="UserId" type="xsd:long" minOccurs="1" maxOccurs="1"/>
<xsd:element name="SalesId" type="xsd:long" minOccurs="1" maxOccurs="1"/>
<xsd:element name="TotalDue" type="xsd:decimal" minOccurs="1" maxOccurs="1"/>
<xsd:element name="ChangeDue" type="xsd:decimal" minOccurs="1" maxOccurs="1"/>
**<xsd:element ref="tns:tenderItem" minOccurs="0" maxOccurs="unbounded"/>**
<xsd:element name="ProtectionPlans" type="tns:ProtectionPlanItemType" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="InsurancePlans" type="tns:FeatureItemType" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
注意tenderItems 是一个参考。它的来源在这里:
<xsd:element abstract="true" name="tenderItem" type="tns:TenderType"/>
<xsd:complexType name="TenderType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="date" type="xsd:dateTime"/>
<xsd:element maxOccurs="1" minOccurs="0" name="lineNumber" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="tenderId" type="xsd:long"/>
<xsd:element maxOccurs="1" minOccurs="0" name="returnTenderId" type="xsd:long"/>
<xsd:element maxOccurs="1" minOccurs="0" name="tenderType" type="tns:TenderTypeType"/>
<xsd:element maxOccurs="1" minOccurs="0" name="amount" type="xsd:decimal"/>
<xsd:element maxOccurs="1" minOccurs="0" name="signature" type="tns:SignatureType"/>
</xsd:sequence>
</xsd:complexType>
有几个扩展tenderType 的特定投标,我想将它们添加到我的Xquery 请求中。这是一个例子:
<xsd:element name="billToAccount" substitutionGroup="tns:tenderItem" type="tns:BillToAccountType"/>
<xsd:complexType name="BillToAccountType">
<xsd:complexContent>
<xsd:extension base="tns:TenderType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="accountId" type="xsd:long"/>
<xsd:element maxOccurs="1" minOccurs="0" name="subscriptionId" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="chargeDescription" type="xsd:string"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="lineItems" type="tns:BillToAccountLineItemType"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
那么这在 Xquery 中是如何完成的呢?我尝试了以下方法:
{
for $BillToAccount in $addInsuranceToOrderABM1/ns3:MessagePayload/ns3:AddInsuranceToOrder/ns1:AddInsuranceToOrderDataArea/ns2:TenderItem
return
<ns2:billToAccount>
{
for $Date in $BillToAccount/ns0:Date
return
<ns2:date>{ data($Date) }</ns2:date>
}…
}
我为每个tenderType 都这样做了,但是映射器不支持XML 元素。