“AsmXml”错误的“架构”

时间:2012-06-10 17:48:22

标签: xml assembly xml-parsing

根据asmxml我有一个问题。 我尝试将模式写入xml文件。架构如下所示:

<schema>
        <document name="XRF">
                <collection name="IL">
                        <attribute name="k"/>
                        <collection name="I">
                                <attribute name="k"/>
                                <collection name="M">
                                        <attribute name="k"/>
                                        <attribute name="v"/>
                                </collection>
                                <collection name="P">
                                        <attribute name="k"/>
                                        <attribute name="v"/>
                                        <attribute name="t"/>
                                        <attribute name="d"/>
                                </collection>
                        </collection>
                </collection>
        </document>
</schema>

这里是XML文件的片段:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE XRF SYSTEM "/apid/xml/xrf.dtd">-->
<XRF r="8.5.2" c="iD2" g="" u="DE23580-apiinlife03" k="918887283" d="20120523" t="235602">
<IL k="1">              
<I k="1007667,361,402"> 
<M k="3" v="GB0008762899"/>     
<M k="187" v="BG Group" l="4"/> 
<P k="33,3,2" v="13.065" t="181502" d="20120522" y="524" n="0" b="779"/>
<P k="2,1,1" v="12.56" t="080025" d="20120523" z="74876" y="272" n="459" b="908"/>
<P k="41,1,1" s="5"/>           
<P k="9,3,2" v="12.73" t="163519" d="20120522" z="8322" y="158" n="0" b="779"/>                  
</I>
</IL>
</XRF>

有人可以帮我修复“架构”吗?我不知道我做错了什么。 提前谢谢。

问候 ž。

1 个答案:

答案 0 :(得分:2)

老问题,但也许它可以帮助一些新用户登陆这里。 在使用AsmXML定义模式时,您无法直接覆盖这样的集合。

您宁愿通过在<document>部分之外定义集合来链接对要使用的集合的相应定义的引用。例如,您的案例中的正确架构将是:

<schema>
    <collection name="M">
        <attribute name="k"/>
        <attribute name="v"/>
    </collection>

    <collection name="P">
        <attribute name="k"/>
        <attribute name="v"/>
        <attribute name="t"/>
        <attribute name="d"/>
    </collection>

    <collection name="I">
        <attribute name="k"/>
        <reference name="M"/>
        <reference name="P"/>
    </collection>

    <document name="XRF">
            <collection name="IL">
                    <attribute name="k"/>
                    <reference name="I" />
            </collection>
    </document>
</schema>

此外,请确保包含集合中所需的所有属性,您也可以使用组来执行此操作。 可以在那里找到更多:http://tibleiz.net/asm-xml/documentation.html

希望这有帮助!