【问题标题】:Getting C++ object from xsd:extension从 xsd:extension 获取 C++ 对象
【发布时间】:2015-06-05 09:21:20
【问题描述】:

我正在使用来自代码合成的 xsd 到 c++ 编译器。我正在编译这些 xsd sn-ps:

<xsd:complexType name="elementBaseType">
    <xsd:sequence>
        <xsd:element name="init" type="initElementType"/>
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="BUTTON_ELEMENT">
    <xsd:complexContent>
        <xsd:extension base="elementBaseType">
            <xsd:sequence>
                <xsd:element name="imageClicked" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>

在我的 c++ 代码中,我可以获得 elementBaseType 的所有信息。但我也需要来自我的专业 BUTTON_ELEMENT 的信息。我记录了解析步骤,似乎从未调用过 BUTTON_ELEMENT 的构造函数。但是,对于我的 XML 文件中的每个 BUTTON_ELEMENT,都会调用 elementBaseType 构造函数。

我错过了什么吗? 我使用这个命令来生成 c++ 文件:

cxx-tree --std c++11 --generate-polymorphic --output-dir C:/generated Configuration.xsd

【问题讨论】:

    标签: c++ xml xsd xml-parsing codesynthesis


    【解决方案1】:

    您很可能错过了 --polymorphic-type 命令行选项。

    这是CodeSynthesis XSD/Tree Manual的引述:

    “但是,如果您的 XML 词汇表没有使用替换组,或者如果替换组是在单独的模式中定义的,那么您将需要使用 --polymorphic-type 选项来指定哪些类型是多态的。”

    在此处阅读有关 --polymorphic-type 命令行选项的更多详细信息:

    CodeSynthesis XSD/Tree command line options

    【讨论】:

    • 谢谢,帮了大忙!
    猜你喜欢
    • 2010-11-18
    • 1970-01-01
    • 2018-11-15
    • 2016-10-04
    • 2011-04-09
    • 1970-01-01
    • 2017-11-04
    • 1970-01-01
    • 2020-04-08
    相关资源
    最近更新 更多