架构更改无效

时间:2014-07-31 10:10:19

标签: xml relaxng

我有一个名为a.rnc的架构,看起来像这样

default namespace = "urn:schemas-foo:bar"
include "b.rnc" {
        start = A
        Links = element link { HidableLinkType }*
    }

A = element Bat { AType }

AType = SavedResourceType 
                & Boundary?
                & Baz*
                & element link { HidableLinkType }*

我有另一个名为b.rnc的模式,过去看起来像这样

default namespace = "urn:schemas-foo:bar"
include "c.rnc"
include "d.rnc" {
        start = Baz
    }

Baz = element Z { BType }

BType = SavedResourceType

SavedResourceType &= Boundary?
                  &  element panel-id { text }?
                  &  Annotations?                          

Boundary = element boundary { "a" | "b" | Bounds }

Bounds = (
        attribute from { xsd:date },
        attribute to { xsd:date }
    )

但我将最后一位(因为xml结构已更改)更改为

Boundary = element boundary { Bounds }

    Bounds = (
            attribute from { "a" | "b" | xsd:date },
            attribute to { "a" | "b" | xsd:date }
        )

我已经生成了rng文件,但是当运行的代码运行验证这些模式时,我得到以下错误

POST <url> 400 (Invalid attribute value is found. Value = 'a' Expected elements are: . line 7, column 13   Validated using schema:   b.rng) 

我在这里做些蠢事吗?

2 个答案:

答案 0 :(得分:5)

您是否已连接到具有更新架构的本地计算机,或者您是否已连接到在发出验证请求时已过期的远程服务器?

在更改任何代码之前,您应该停止粘贴您正在处理的代码。那只是懒惰。你可能会被解雇。

答案 1 :(得分:1)

简化架构

start = element boundary { Bounds }

Bounds = (
    attribute from { "published" | "global" | xsd:date },
    attribute to { "published" | "global" | xsd:date }
)

验证此XML代码段就好了:

<?xml version="1.0" encoding="UTF-8"?>
<boundary from="published" to="published"/>

你能拦截你的XML(从JSON转换后),看看它是否合适?