簡體   English   中英

這個XSD有什么問題? 如何驗證XSD?

[英]What is wrong with this XSD? how to validate XSD?

我觀察到以下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>  

架構似乎唯一的錯誤是您缺少結束標記

</xs:schema> 

在末尾。 但是,您的架構似乎不完整,不能用於驗證給定的XML文檔,因為它沒有聲明<SecurityAllocation...>標記。 XML文檔也缺少其結束標記BTW。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM