首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >验证手动生成的xml模式

验证手动生成的xml模式
EN

Stack Overflow用户
提问于 2014-06-02 20:29:47
回答 1查看 346关注 0票数 0

我正在尝试用JSF/J2EE开发一个应用程序:多维分析应用程序,我生成一个Schema文件,现在我想用mondrian.xsd来验证它--这是我生成的代码:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Schema description="test shcema description" name="First Schema9">
    <Cube cache="true" 
          caption="code here" 
          description="cubeInSchema" 
          enabled="true" 
          name="First Cube7"/>
    <Parameter defaultValue="admin" 
               description="parameter role" 
               modifiable="true" 
               name="param name" 
               type="String"/>
</Schema>

但我在验证中得到了以下错误:

代码语言:javascript
复制
**cvc-complex-type.2.4.b: The content of the element "Cube" is not complete. One of the values ​​"{Annotations, Table, View}" is expected.**

==>但是我不认为我们应该在每个立方体中有一个{AnnotationsTableView}。我不知道如何验证我的mondrian模式。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-02 21:06:36

mondrian.xsd XSD中,Cube元素声明为:

代码语言:javascript
复制
<xsd:element name="Cube" minOccurs="1" maxOccurs="unbounded">
    ...
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="Annotations" type="Annotations" minOccurs="0" maxOccurs="1"/>
            <xsd:group ref="FactTable" minOccurs="1" maxOccurs="1">
                ...
            </xsd:group>
            <xsd:choice minOccurs="1" maxOccurs="unbounded">
                <xsd:element name="DimensionUsage" type="DimensionUsage"/>
                <xsd:element name="Dimension" type="PrivateDimension"/>
            </xsd:choice>
            <xsd:element name="Measure" minOccurs="1" maxOccurs="unbounded">
                ...

然后声明chid <Annotations>元素是可选的(minOccurs="0"),但是FactTable组中的元素、<Dimension><DimensionUsage>以及<Measure>元素必须按照这个顺序出现。

搜索您找到的FactTable组:

代码语言:javascript
复制
<xsd:group name="FactTable">
    <xsd:choice>
        <xsd:element name="Table" type="Table"/>
        <xsd:element name="View" type="View"/>
    </xsd:choice>
</xsd:group>

这意味着<Cube>中强制的元素是<View> (或<Table>)、<Dimension> (或<DimensionUsage>)和<Measure>。如果它们不存在,则您的实例将不会验证。

此外,在<Schema>序列中还有一个强制顺序:<View>必须出现在<Parameter>之后(而不是像您的示例中那样)。

我根据您的文件从mondrian.xsd模式生成了一个最小的验证文件。考虑到选项DimensionView,所有这些都是强制性的:

代码语言:javascript
复制
<Schema description="test shcema description" name="First Schema9">
    <Parameter defaultValue="admin" 
               description="parameter role" 
               modifiable="true"
               name="param name" 
               type="String"/>
    <Cube cache="true" 
          caption="code here" 
          description="cubeInSchema" 
          enabled="true"
          name="First Cube7">

        <View alias="aaa">
            <SQL dialect="sss"></SQL>
        </View>
        <Dimension name="bbb">
            <Annotations>
                <Annotation></Annotation>
            </Annotations>
            <Hierarchy hasAll="false">
                <Level name="ccc"></Level>
            </Hierarchy>
        </Dimension>
        <Measure name="ddd" aggregator="max"/>
    </Cube>
</Schema>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24002731

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档