这个XSD有什么问题?如何验证XSD?

时间:2016-03-05 19:03:45

标签: xml xsd xsd-validation

我发现以下XSD文件已损坏。如何验证XSD?之后我还包括我的XML文件。我的同行已经建议它应该验证为true,但是XDS中缺少了一些东西。

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.salerio.com/External/1" xmlns="http://www.salerio.com/External/1"
       elementFormDefault="qualified">

<xs:complexType name="counterparty">
    <xs:sequence>
        <xs:element name="Reference" type="xs:string"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="price">
     <xs:annotation>
         <xs:documentation>
             An amount.
         </xs:documentation>
     </xs:annotation>
     <xs:sequence>
         <xs:element name="Type" type="xs:string"/>
         <xs:element name="Currency" type="currency"/>
         <xs:element name="Amount" type="xs:decimal"/>
     </xs:sequence>
 </xs:complexType>

<xs:complexType name="amount">
    <xs:annotation>
        <xs:documentation>
            An amount.
        </xs:documentation>
    </xs:annotation>
    <xs:sequence>
        <xs:element name="Currency" type="currency"/>
        <xs:element name="Amount" type="xs:decimal"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="securityReferenceType">
    <xs:simpleContent>
        <xs:extension base="xs:string">
            <xs:attribute name="Type" use="required">
                <xs:simpleType>
                    <xs:annotation>
                        <xs:documentation>
                            The type of a security reference.
                        </xs:documentation>
                    </xs:annotation>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="ISIN"/>
                        <xs:enumeration value="CUSIP"/>
                        <xs:enumeration value="SEDOL"/>
                        <!-- Not sure what this should be called -->
                        <xs:enumeration value="Ticker"/>
                        <xs:enumeration value="Other"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:extension>
    </xs:simpleContent>
</xs:complexType>

<xs:complexType name="quantityType">
    <xs:simpleContent>
        <xs:extension base="positiveDecimal">
            <xs:attribute name="Type" use="required">
                <xs:simpleType>
                    <xs:annotation>
                        <xs:documentation>
                            The type of the quantity.
                        </xs:documentation>
                    </xs:annotation>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="Face"/>
                        <xs:enumeration value="Unit"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:extension>
    </xs:simpleContent>
</xs:complexType>


<xs:simpleType name="reference">
    <xs:annotation>
        <xs:documentation>
            An OMS reference.
        </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:minLength value="1"/>
        <xs:maxLength value="16"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="buySell">
    <xs:annotation>
        <xs:documentation>
            Whether buying or selling the security.
        </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:enumeration value="Buy"/>
        <xs:enumeration value="Sell"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="longShort">
    <xs:annotation>
        <xs:documentation>
            Whether the trade is going Long or Short.
        </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:enumeration value="Long"/>
        <xs:enumeration value="Short"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="yesNo">
    <xs:annotation>
        <xs:documentation>
            Whether the trade is going Long or Short.
        </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:enumeration value="Yes"/>
        <xs:enumeration value="No"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="bargainCondition">
    <xs:annotation>
        <xs:documentation>
            The bargain condition of the trade.
        </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:enumeration value="CumDividend"/>
        <xs:enumeration value="ExDividend"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="positiveDecimal">
    <xs:restriction base="xs:decimal">
        <xs:minInclusive value="0.0"/>
    </xs:restriction>
</xs:simpleType>

<xs:simpleType name="currency">
    <xs:restriction base="xs:string">
        <xs:minLength value="3"/>
        <xs:maxLength value="3"/>
    </xs:restriction>
</xs:simpleType>
</xs:schema>

和我的XML:

<SecurityAllocation xmlns="http://www.salerio.com/External/1">
<Function>New</Function>
<OrderManagementSystem>
    <Reference>CLIENT</Reference>
    <TradeIdentifier>OMSA10002</TradeIdentifier>
</OrderManagementSystem>
<AllocationIdentifier>A10002</AllocationIdentifier>
<ExecutionIdentifier>B10001</ExecutionIdentifier>
<ExecutionDetails>
    <ExecutingBroker>
        <Reference>MERRIL</Reference>
    </ExecutingBroker>
    <BuySell>Sell</BuySell>
    <LongShort>Long</LongShort>
    <Security>
        <Type>COM</Type>
        <Description>EMC CORPORATION</Description>
        <References>
            <Reference Type="ISIN">US2686481027</Reference>
            <Reference Type="CUSIP">268648102</Reference>
        </References>
    </Security>
    <Price>
        <Type>Clean</Type>
        <Currency>USD</Currency>
        <Amount>28.6726</Amount>
    </Price>
    <TradeDate>2014-10-01</TradeDate>
    <TradeTime>09:30:47</TradeTime>
    <SettlementDate>2014-10-06</SettlementDate>
    <Market>US</Market>
    <FreeOfPayment>No</FreeOfPayment>
    <Trader>
        <Desk>Death Star</Desk>
        <Name>Jeff Vader</Name>
        <Location>Alderaan</Location>
    </Trader>
</ExecutionDetails> 
<AllocationDetails>
    <Portfolio>
        <Reference>PORTFOLIO2</Reference>
    </Portfolio>
    <Quantity Type="Unit">301837.00</Quantity>
    <GrossAmount>
        <Currency>USD</Currency>
        <Amount>8654451.57</Amount>
    </GrossAmount>
    <Charges>
        <Charge Type="Issuer">
            <Currency>USD</Currency>
            <Amount>191.27</Amount>             
        </Charge>
    </Charges>
    <Commissions>
        <Commission Type="Broker">
            <Currency>USD</Currency>
            <Amount>12073.48</Amount>               
        </Commission>
    </Commissions>      
    <NetAmount>
        <Currency>USD</Currency>
        <Amount>8642186.82</Amount>
    </NetAmount>
    <SettlementAmount>
        <Currency>USD</Currency>
        <Amount>8642186.82</Amount>
    </SettlementAmount>
</AllocationDetails>
<Related>
    <Rebooked>No</Rebooked>
</Related>  

1 个答案:

答案 0 :(得分:0)

模式似乎唯一错误的是您缺少结束标记

</xs:schema> 

最后。但是,您的架构似乎不完整,不能用于验证给定的XML文档,因为它没有声明<SecurityAllocation...>标记。 XML文档也缺少其结束标记BTW。