Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
2009-01-20 Atsushi Enomoto <atsushi@ximian.com>
* RelaxngDatatypeProviderTests.cs : new test, based on bug #463267
by Mark Junker.
2009-01-20 Atsushi Enomoto <atsushi@ximian.com>
* RelaxngDatatypeProviderTests.cs : new test, based on bug #463264
by Mark Junker.
2008-11-11 Atsushi Enomoto <atsushi@ximian.com>
* RncTests.cs : added InheritDefaultNamespace().
2007-12-14 Atsushi Enomoto <atsushi@ximian.com>
* RelaxngReaderTests.cs : added test for bug #347945.
2006-04-18 Atsushi Enomoto <atsushi@ximian.com>
* RncTests.cs : added (my own) infocard rnc parsing test.
2006-04-11 Atsushi Enomoto <atsushi@ximian.com>
* NvdlValidatingReaderTests.cs : new file for NVDL test.
2006-04-04 Atsushi Enomoto <atsushi@ximian.com>
* RncTests.cs : added atom.rnc parsing test.
2006-04-04 Atsushi Enomoto <atsushi@ximian.com>
* RncTests.cs : added surrogate test and foreign-elements/attributes
ambiguity test.
2006-01-04 Atsushi Enomoto <atsushi@ximian.com>
* RelaxngValidatingReaderTests.cs : regressions mentioned in the
previous fix were solved.
2006-01-03 Atsushi Enomoto <atsushi@ximian.com>
* RelaxngValidatingReaderTests.cs : seems like there are some sort
of regressions. Will be fixed after my end of vacations.
2004-05-30 Atsushi Enomoto <atsushi@ximian.com>
* RncTests.cs : fixed test that got impossible to build anymore.
2004-05-08 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* RelaxngValidatingReaderTests.cs: this compiled with mcs but fails with
csc. Filed as bug #58222.
2004-03-17 Atsushi Enomoto <atsushi@ximian.com>
* Added RncTests.cs (compact syntax test).
* RelaxngReaderTests.cs : modified and fixed relaxng.rng reading test.
* RelaxngValidatingReaderTests.cs : Added relaxng.rng validation test.
2004-02-28 Atsushi Enomoto <atsushi@ximian.com>
* Removed Commons.Xml.Relaxng_test.args.
* RelaxngReaderTests.cs,
RelaxngValidatingReaderTests.cs : file path fix.
* XsdDatatypeTests.cs : It causes infinite loop (maybe bug in libs),
so comment out right now.
2004-02-28 Atsushi Enomoto <atsushi@ximian.com>
* Added XsdDatatypeTests.cs.
* RdpPatternTests.cs,
RelaxngReaderTests.cs,
RelaxngValidatingReaderTests.cs : library class change fixes.
2003-05-13 Martin Willemoes Hansen <mwh@sysrq.dk>
* makefile.gnu: Fixed name of assembly was changed
from Mono.Xml.Relaxng to
Commons.Xml.Relaxng.
* RdpPatternTests.cs, RelaxngReaderTests.cs:
Removed Assertion. prefixes and made them inherit from Assertion.
2003-04-29 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* Started.
* added ChangeLog, RdpPatternTests.cs, RelaxngReaderTests.cs,
RelaxngValidatingReaderTests.cs, makefile.gnu,
Commons.Xml.Relaxng_test.args and Commons.Xml.Relaxng_test.build.

View File

@@ -0,0 +1,47 @@
//
// NvdlValidatingReaderTests.cs
//
// Authors:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell Inc.
//
using System;
using System.IO;
using System.Xml;
using Commons.Xml.Nvdl;
using NUnit.Framework;
namespace MonoTests.Commons.Xml.Nvdl
{
[TestFixture]
public class NvdlValidatingReaderTests
{
[Test]
public void ReadNvdlNvdl ()
{
using (TextReader r = File.OpenText ("Test/XmlFiles/nvdl.nvdl")) {
NvdlRules rules = NvdlReader.Read (
new XmlTextReader (r));
}
}
[Test]
public void ValidateNvdlNvdl ()
{
NvdlRules rules = null;
string path = "Test/XmlFiles/nvdl.nvdl";
using (TextReader r = File.OpenText (path)) {
rules = NvdlReader.Read (
new XmlTextReader (path, r));
}
using (TextReader r = File.OpenText (path)) {
XmlTextReader xtr = new XmlTextReader (path, r);
NvdlValidatingReader vr = new NvdlValidatingReader (xtr, rules);
while (!vr.EOF)
vr.Read ();
}
}
}
}

View File

@@ -0,0 +1,53 @@
//
// RdpPatternTests.cs
//
// Authors:
// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
//
// (C) 2003 Atsushi Enomoto
//
using System;
using System.IO;
using System.Xml;
using Commons.Xml.Relaxng;
using Commons.Xml.Relaxng.Derivative;
using NUnit.Framework;
namespace MonoTests.Commons.Xml.Relaxng
{
[TestFixture]
public class RdpPatternTests
{
RelaxngValidatingReader reader;
RdpPattern result;
RdpPattern pattern1;
[SetUp]
public void SetUp ()
{
pattern1 = new RdpElement (new RdpName ("foo", "urn:foo"), RdpEmpty.Instance);
}
private void AssertPattern (string s, RelaxngPatternType expected, RdpPattern p)
{
Assert.AreEqual (expected, p.PatternType, s);
}
[Test]
public void ElementStartTagOpenDeriv ()
{
result = pattern1.StartTagOpenDeriv ("bar", "urn:foo");
AssertPattern ("#element.start.1", RelaxngPatternType.NotAllowed, result);
result = pattern1.StartTagOpenDeriv ("foo", "urn:bar");
AssertPattern ("#element.start.2", RelaxngPatternType.NotAllowed, result);
result = pattern1.StartTagOpenDeriv ("foo", "urn:foo");
AssertPattern ("#element.start.3", RelaxngPatternType.After, result);
RdpAfter after= result as RdpAfter;
AssertPattern ("#element.start.4", RelaxngPatternType.Empty, after.LValue);
AssertPattern ("#element.start.5", RelaxngPatternType.Empty, after.RValue);
}
}
}

View File

@@ -0,0 +1,98 @@
//
// RelaxngDatatypeProviderTest.cs
//
// Authors:
// Atsushi Enomoto <atsushi@ximian.com>
//
using System;
using System.IO;
using System.Xml;
using Commons.Xml.Relaxng;
using Commons.Xml.Relaxng.XmlSchema;
using NUnit.Framework;
namespace MonoTests.Commons.Xml.Relaxng
{
[TestFixture]
public class RelaxngDatatypeProviderTests
{
[Test]
public void CustomTypeProvider ()
{
var datatypeLibrary = SetupMyDataProvider ();
XmlDocument xml = new XmlDocument ();
xml.LoadXml ("<root> <v1>mytype</v1> <v2>1</v2> </root>");
XmlDocument schemaXml = ReadDoc ("Test/XmlFiles/463264.rng");
XmlReader reader = new RelaxngValidatingReader (new XmlNodeReader (xml), new XmlNodeReader (schemaXml), datatypeLibrary);
while (reader.Read ())
;
}
[Test]
public void Bug463267 ()
{
var datatypeLibrary = SetupMyDataProvider ();
XmlDocument xml = new XmlDocument ();
xml.LoadXml ("<root> <v2>1</v2> <v1>mytype</v1> </root>");
XmlDocument schemaXml = ReadDoc ("Test/XmlFiles/463267.rng");
XmlReader reader = new RelaxngValidatingReader (new XmlNodeReader (xml), new XmlNodeReader (schemaXml), datatypeLibrary);
while (reader.Read ())
;
}
RelaxngDatatypeProvider SetupMyDataProvider ()
{
var datatypeLibrary = new RelaxngMergedProvider ();
datatypeLibrary [MyRngTypeProvider.Namespace] = new MyRngTypeProvider();
datatypeLibrary ["http://www.w3.org/2001/XMLSchema-datatypes"] = XsdDatatypeProvider.Instance;
datatypeLibrary [System.Xml.Schema.XmlSchema.Namespace] = XsdDatatypeProvider.Instance;
datatypeLibrary [String.Empty] = RelaxngMergedProvider.DefaultProvider [string.Empty];
return datatypeLibrary;
}
XmlDocument ReadDoc (string s)
{
var d = new XmlDocument ();
d.Load (s);
return d;
}
}
class MyRngTypeProvider : RelaxngDatatypeProvider
{
public static readonly string Namespace = "http://tempuri.org/mytypes";
public override RelaxngDatatype GetDatatype(string name, string ns, RelaxngParamList parameters)
{
switch (name)
{
case "mytype":
return new MyType();
}
return null;
}
}
class MyType : RelaxngDatatype
{
public override string Name {
get { return "mytype"; }
}
public override string NamespaceURI {
get { return MyRngTypeProvider.Namespace; }
}
public override object Parse (string text, System.Xml.XmlReader reader)
{
return text;
}
public override bool IsValid (string text, System.Xml.XmlReader reader)
{
return ((string) Parse (text, reader)) == "mytype";
}
}
}

View File

@@ -0,0 +1,66 @@
//
// RelaxngReaderTests.cs
//
// Authors:
// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
//
// (C) 2003 Atsushi Enomoto
//
using System;
using System.IO;
using System.Xml;
using Commons.Xml.Relaxng;
using NUnit.Framework;
namespace MonoTests.Commons.Xml.Relaxng
{
[TestFixture]
public class RelaxngReaderTests
{
RelaxngReader reader;
[SetUp]
public void SetUp ()
{
}
private void loadGrammarFromUrl (string url)
{
reader = new RelaxngReader (new XmlTextReader (url));
}
[Test]
public void SimpleRead ()
{
loadGrammarFromUrl ("Test/XmlFiles/SimpleElementPattern1.rng");
RelaxngPattern p = reader.ReadPattern ();
Assert.AreEqual (RelaxngPatternType.Element, p.PatternType);
}
[Test]
public void CompileRelaxngGrammar ()
{
loadGrammarFromUrl ("Test/XmlFiles/relaxng.rng");
RelaxngPattern p = reader.ReadPattern ();
Assert.AreEqual (RelaxngPatternType.Grammar, p.PatternType);
p.Compile ();
}
[Test]
public void Bug347945 ()
{
string rng = @"
<element name='x' xmlns='http://relaxng.org/ns/structure/1.0'>
<interleave>
<element name='y'><text/></element>
<element name='z'><text/></element>
</interleave>
</element>";
RelaxngPattern p = RelaxngPattern.Read (new XmlTextReader (rng, XmlNodeType.Document, null));
}
}
}

View File

@@ -0,0 +1,84 @@
//
// RelaxngValidatingReaderTests.cs
//
// Authors:
// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
//
// (C) 2003 Atsushi Enomoto
//
using System;
using System.IO;
using System.Xml;
using Commons.Xml.Relaxng;
using NUnit.Framework;
using RVR = Commons.Xml.Relaxng.RelaxngValidatingReader;
namespace MonoTests.Commons.Xml.Relaxng
{
[TestFixture]
public class RelaxngValidatingReaderTests
{
RelaxngValidatingReader reader;
[SetUp]
public void SetUp ()
{
}
private void SetupReaderFromUrl (string instanceUrl, string grammarUrl)
{
reader = new RelaxngValidatingReader (
new XmlTextReader (instanceUrl),
new XmlTextReader (grammarUrl));
}
private void SetupReader (string instance, string grammar)
{
reader = new RelaxngValidatingReader (
new XmlTextReader (new StringReader (instance)),
new XmlTextReader (new StringReader (grammar)));
}
[Test]
public void SimpleElementPattern1 ()
{
SetupReaderFromUrl ("Test/XmlFiles/SimpleElementPattern1.xml",
"Test/XmlFiles/SimpleElementPattern1.rng");
while (!reader.EOF)
reader.Read ();
}
[Test]
public void SimpleElementPattern2 ()
{
SetupReaderFromUrl ("Test/XmlFiles/SimpleElementPattern2.xml",
"Test/XmlFiles/SimpleElementPattern2.rng");
while (!reader.EOF)
reader.Read ();
}
[Test]
public void ReadPracticalSample1 ()
{
SetupReaderFromUrl ("Test/XmlFiles/team.xml", "Test/XmlFiles/team.rng");
while (!reader.EOF)
reader.Read ();
}
[Test]
public void ValidateRelaxngGrammar ()
{
// validate relaxng.rng with relaxng.rng
RVR r = new RVR (
new XmlTextReader ("Test/XmlFiles/relaxng.rng"),
new XmlTextReader ("Test/XmlFiles/relaxng.rng"));
while (!r.EOF)
r.Read ();
}
}
}

View File

@@ -0,0 +1,99 @@
//
// RncTests.cs
//
// Authors:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (C) 2004 Novell Inc.
//
using System;
using System.IO;
using System.Text;
using System.Xml;
using Commons.Xml.Relaxng;
using Commons.Xml.Relaxng.Rnc;
using NUnit.Framework;
namespace MonoTests.Commons.Xml.Relaxng
{
[TestFixture]
public class RncTests
{
RelaxngPattern Compile (string file)
{
using (StreamReader sr = new StreamReader (file)) {
return Compile (sr, file);
}
}
RelaxngPattern Compile (TextReader reader)
{
return Compile (reader, null);
}
RelaxngPattern Compile (TextReader reader, string baseUri)
{
RncParser parser = new RncParser (new NameTable ());
RelaxngPattern g = parser.Parse (reader, baseUri);
g.Compile ();
return g;
}
[Test]
public void TestRelaxngRnc ()
{
Compile ("Test/XmlFiles/relaxng.rnc");
}
[Test]
public void TestAtomRnc ()
{
Compile ("Test/XmlFiles/atom.rnc");
}
[Test]
public void TestInfocardRnc ()
{
Compile ("Test/XmlFiles/schemas-xmlsoap-or-ws-2005-05-identity.rnc");
}
[Test]
// Make sure that it is not rejected by ambiguity between
// foreign attribute and foreign element.
public void Annotations ()
{
string rnc = @"
namespace s = ""urn:foo""
mine =
[
s:foo []
s:foo = ""value""
]
element foo { empty }
start = mine";
Compile (new StringReader (rnc));
}
[Test]
public void SurrogateLiteral ()
{
Compile (new StringReader ("element foo { \"\\x{10FFFF}\" }"));
}
[Test]
public void InheritDefaultNamespace ()
{
RelaxngPattern g = Compile ("Test/XmlFiles/include-default-namespace.rnc");
XmlReader xtr = new XmlTextReader ("Test/XmlFiles/include-default-namespace.xml");
RelaxngValidatingReader r = new RelaxngValidatingReader (xtr, g);
try {
while (!r.EOF)
r.Read ();
} finally {
r.Close ();
}
}
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="root">
<element name="v1">
<data type="mytype" datatypeLibrary="http://tempuri.org/mytypes" />
</element>
<element name="v2">
<data type="int" />
</element>
</element>
</start>
</grammar>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://tempuri.org/mytypes">
<start>
<element name="root">
<element name="v2">
<data type="int" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<param name="minExclusive">0</param>
<param name="maxExclusive">10</param>
</data>
</element>
<element name="v1">
<data type="mytype" />
</element>
</element>
</start>
</grammar>

View File

@@ -0,0 +1,38 @@
2009-01-20 Atsushi Enomoto <atsushi@ximian.com>
* 463267.rng : new test file.
2009-01-20 Atsushi Enomoto <atsushi@ximian.com>
* 463264.rng : new test file.
2008-11-11 Atsushi Enomoto <atsushi@ximian.com>
* include-default-namespace.rnc,
include-default-namespace-included.rnc,
include-default-namespace.xml : new test files.
2007-04-18 Atsushi Enomoto <atsushi@ximian.com>
* schemas-xmlsoap-or-ws-2005-05-identity.rnc : new test schema.
2006-04-11 Atsushi Enomoto <atsushi@ximian.com>
* nvdl.nvdl, nvdl.rng : new file for nvdl validation.
2006-04-04 Atsushi Enomoto <atsushi@ximian.com>
* atom.rnc : new file for RNC parser test (It is from
http://atompub.org/2005/08/17/atom.rnc i.e.
http://www.ietf.org/rfc/rfc4287.txt).
2004-03-17 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* Added relaxng.rng and relaxng.rnc.
2003-04-29 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* Started.
* added ChangeLog, SimpleElementPattern1.xml, SimpleElementPattern1.rng,
SimpleElementPattern2.xml, SimpleElementPattern2.rng, team.xml,
team.rng.

View File

@@ -0,0 +1,5 @@
<element xmlns="http://relaxng.org/ns/structure/1.0" name="foo">
<element name='bar'>
<empty/>
</element>
</element>

View File

@@ -0,0 +1 @@
<foo><bar /></foo>

View File

@@ -0,0 +1,8 @@
<element xmlns="http://relaxng.org/ns/structure/1.0" name="foo">
<element name='bar'>
<element name='baz'><empty/></element>
</element>
<element name='hoge'>
<element name='fuga'><empty/></element>
</element>
</element>

View File

@@ -0,0 +1,4 @@
<foo>
<bar><baz/></bar>
<hoge><fuga/></hoge>
</foo>

View File

@@ -0,0 +1,339 @@
# -*- rnc -*-
# RELAX NG Compact Syntax Grammar for the
# Atom Format Specification Version 11
namespace atom = "http://www.w3.org/2005/Atom"
namespace xhtml = "http://www.w3.org/1999/xhtml"
namespace s = "http://www.ascc.net/xml/schematron"
namespace local = ""
start = atomFeed | atomEntry
# Common attributes
atomCommonAttributes =
attribute xml:base { atomUri }?,
attribute xml:lang { atomLanguageTag }?,
undefinedAttribute*
# Text Constructs
atomPlainTextConstruct =
atomCommonAttributes,
attribute type { "text" | "html" }?,
text
atomXHTMLTextConstruct =
atomCommonAttributes,
attribute type { "xhtml" },
xhtmlDiv
atomTextConstruct = atomPlainTextConstruct | atomXHTMLTextConstruct
# Person Construct
atomPersonConstruct =
atomCommonAttributes,
(element atom:name { text }
& element atom:uri { atomUri }?
& element atom:email { atomEmailAddress }?
& extensionElement*)
# Date Construct
atomDateConstruct =
atomCommonAttributes,
xsd:dateTime
# atom:feed
atomFeed =
[
s:rule [
context = "atom:feed"
s:assert [
test = "atom:author or not(atom:entry[not(atom:author)])"
"An atom:feed must have an atom:author unless all "
~ "of its atom:entry children have an atom:author."
]
]
]
element atom:feed {
atomCommonAttributes,
(atomAuthor*
& atomCategory*
& atomContributor*
& atomGenerator?
& atomIcon?
& atomId
& atomLink*
& atomLogo?
& atomRights?
& atomSubtitle?
& atomTitle
& atomUpdated
& extensionElement*),
atomEntry*
}
# atom:entry
atomEntry =
[
s:rule [
context = "atom:entry"
s:assert [
test = "atom:link[@rel='alternate'] "
~ "or atom:link[not(@rel)] "
~ "or atom:content"
"An atom:entry must have at least one atom:link element "
~ "with a rel attribute of 'alternate' "
~ "or an atom:content."
]
]
s:rule [
context = "atom:entry"
s:assert [
test = "atom:author or "
~ "../atom:author or atom:source/atom:author"
"An atom:entry must have an atom:author "
~ "if its feed does not."
]
]
]
element atom:entry {
atomCommonAttributes,
(atomAuthor*
& atomCategory*
& atomContent?
& atomContributor*
& atomId
& atomLink*
& atomPublished?
& atomRights?
& atomSource?
& atomSummary?
& atomTitle
& atomUpdated
& extensionElement*)
}
# atom:content
atomInlineTextContent =
element atom:content {
atomCommonAttributes,
attribute type { "text" | "html" }?,
(text)*
}
atomInlineXHTMLContent =
element atom:content {
atomCommonAttributes,
attribute type { "xhtml" },
xhtmlDiv
}
atomInlineOtherContent =
element atom:content {
atomCommonAttributes,
attribute type { atomMediaType }?,
(text|anyElement)*
}
atomOutOfLineContent =
element atom:content {
atomCommonAttributes,
attribute type { atomMediaType }?,
attribute src { atomUri },
empty
}
atomContent = atomInlineTextContent
| atomInlineXHTMLContent
| atomInlineOtherContent
| atomOutOfLineContent
# atom:author
atomAuthor = element atom:author { atomPersonConstruct }
# atom:category
atomCategory =
element atom:category {
atomCommonAttributes,
attribute term { text },
attribute scheme { atomUri }?,
attribute label { text }?,
undefinedContent
}
# atom:contributor
atomContributor = element atom:contributor { atomPersonConstruct }
# atom:generator
atomGenerator = element atom:generator {
atomCommonAttributes,
attribute uri { atomUri }?,
attribute version { text }?,
text
}
# atom:icon
atomIcon = element atom:icon {
atomCommonAttributes,
(atomUri)
}
# atom:id
atomId = element atom:id {
atomCommonAttributes,
(atomUri)
}
# atom:logo
atomLogo = element atom:logo {
atomCommonAttributes,
(atomUri)
}
# atom:link
atomLink =
element atom:link {
atomCommonAttributes,
attribute href { atomUri },
attribute rel { atomNCName | atomUri }?,
attribute type { atomMediaType }?,
attribute hreflang { atomLanguageTag }?,
attribute title { text }?,
attribute length { text }?,
undefinedContent
}
# atom:published
atomPublished = element atom:published { atomDateConstruct }
# atom:rights
atomRights = element atom:rights { atomTextConstruct }
# atom:source
atomSource =
element atom:source {
atomCommonAttributes,
(atomAuthor*
& atomCategory*
& atomContributor*
& atomGenerator?
& atomIcon?
& atomId?
& atomLink*
& atomLogo?
& atomRights?
& atomSubtitle?
& atomTitle?
& atomUpdated?
& extensionElement*)
}
# atom:subtitle
atomSubtitle = element atom:subtitle { atomTextConstruct }
# atom:summary
atomSummary = element atom:summary { atomTextConstruct }
# atom:title
atomTitle = element atom:title { atomTextConstruct }
# atom:updated
atomUpdated = element atom:updated { atomDateConstruct }
# Low-level simple types
atomNCName = xsd:string { minLength = "1" pattern = "[^:]*" }
# Whatever a media type is, it contains at least one slash
atomMediaType = xsd:string { pattern = ".+/.+" }
# As defined in RFC 3066
atomLanguageTag = xsd:string {
pattern = "[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*"
}
# Unconstrained; it's not entirely clear how IRI fit into
# xsd:anyURI so let's not try to constrain it here
atomUri = text
# Whatever an email address is, it contains at least one @
atomEmailAddress = xsd:string { pattern = ".+@.+" }
# Simple Extension
simpleExtensionElement =
element * - atom:* {
text
}
# Structured Extension
structuredExtensionElement =
element * - atom:* {
(attribute * { text }+,
(text|anyElement)*)
| (attribute * { text }*,
(text?, anyElement+, (text|anyElement)*))
}
# Other Extensibility
extensionElement =
simpleExtensionElement | structuredExtensionElement
undefinedAttribute =
attribute * - (xml:base | xml:lang | local:*) { text }
undefinedContent = (text|anyForeignElement)*
anyElement =
element * {
(attribute * { text }
| text
| anyElement)*
}
anyForeignElement =
element * - atom:* {
(attribute * { text }
| text
| anyElement)*
}
# XHTML
anyXHTML = element xhtml:* {
(attribute * { text }
| text
| anyXHTML)*
}
xhtmlDiv = element xhtml:div {
(attribute * { text }
| text
| anyXHTML)*
}
# EOF

View File

@@ -0,0 +1,5 @@
grammar {
start = root
root = element root { empty }
}

View File

@@ -0,0 +1,4 @@
default namespace = "urn:foo"
include "include-default-namespace-included.rnc"

View File

@@ -0,0 +1 @@
<root xmlns="urn:foo" />

View File

@@ -0,0 +1,82 @@
<?xml version="1.0"?>
<!-- $Id: nvdl.nvdl,v 1.2 2004/05/30 14:37:33 makoto Exp $ -->
<!--
Inline schemas in NVDL schemas are explicitly allowed by nvdl.rnc.
This schema allows other
-->
<rules startMode="root" xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0">
<mode name="root">
<namespace ns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0">
<validate schema="nvdl.rng">
<mode>
<namespace ns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" match="attributes">
<reject/>
</namespace>
<!-- If we do not allow attribute sections for null URIs, we do not need
the following <namespace> -->
<namespace ns="" match="attributes">
<attach/>
</namespace>
<anyNamespace match="elements attributes">
<!-- This action allows any foreign elements and attributes silently. -->
<allow>
<mode>
<anyNamespace>
<attach/>
</anyNamespace>
</mode>
</allow>
</anyNamespace>
</mode>
<context path="schema">
<mode>
<namespace ns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" match="attributes">
<reject/>
</namespace>
<namespace ns="" match="attributes">
<attach/>
</namespace>
<anyNamespace match="attributes">
<allow/>
</anyNamespace>
<anyNamespace match="elements">
<!-- This action allows the entire subtree to be validated against nvdl.rnc. -->
<attach>
<mode>
<anyNamespace>
<attach/>
</anyNamespace>
</mode>
</attach>
</anyNamespace>
<!-- If we do not allow attribute sections for null URIs, we do not need
the following <namespace> -->
</mode>
</context>
<context path="message">
<mode>
<namespace ns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" match="attributes">
<reject/>
</namespace>
<!-- If we do not allow attribute sections for null URIs, we do not need
the following <namespace> -->
<namespace ns="" match="attributes">
<attach/>
</namespace>
<namespace ns="http://www.w3.org/XML/1998/namespace" match="attributes">
<!-- This action allows xml:* to be validated against ndvl.rnc. -->
<attach/>
</namespace>
<anyNamespace match="attributes">
<allow/>
</anyNamespace>
<anyNamespace match="elements">
<reject/>
</anyNamespace>
</mode>
</context>
</validate>
</namespace>
</mode>
</rules>

View File

@@ -0,0 +1,319 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: nvdl.rnc,v 1.5 2005/01/03 01:49:50 makoto Exp makoto $ -->
<grammar xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" ns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="rules">
<optional>
<ref name="schemaType"/>
</optional>
<zeroOrMore>
<ref name="trigger"/>
</zeroOrMore>
<choice>
<zeroOrMore>
<ref name="rule"/>
</zeroOrMore>
<group>
<attribute name="startMode">
<data type="NCName"/>
</attribute>
<oneOrMore>
<ref name="mode"/>
</oneOrMore>
</group>
</choice>
</element>
</start>
<define name="trigger">
<element name="trigger">
<attribute name="ns">
<data type="string"/>
</attribute>
<attribute name="name">
<data type="NCName"/>
</attribute>
</element>
</define>
<define name="mode">
<element name="mode">
<attribute name="name">
<data type="NCName"/>
</attribute>
<zeroOrMore>
<ref name="includedMode"/>
</zeroOrMore>
<zeroOrMore>
<ref name="rule"/>
</zeroOrMore>
</element>
</define>
<define name="includedMode">
<element name="mode">
<optional>
<attribute name="name">
<data type="NCName"/>
</attribute>
</optional>
<zeroOrMore>
<ref name="includedMode"/>
</zeroOrMore>
<zeroOrMore>
<ref name="rule"/>
</zeroOrMore>
</element>
</define>
<define name="rule">
<choice>
<element name="namespace">
<attribute name="ns">
<data type="string"/>
</attribute>
<optional>
<attribute name="wildcard">
<data type="string">
<param name="maxLength">1</param>
</data>
</attribute>
</optional>
<ref name="ruleModel"/>
</element>
<element name="anyNamespace">
<ref name="ruleModel"/>
</element>
</choice>
</define>
<define name="ruleModel">
<optional>
<attribute name="match">
<ref name="elementsOrAttributes"/>
</attribute>
</optional>
<ref name="actions"/>
</define>
<define name="elementsOrAttributes">
<list>
<choice>
<group>
<value>elements</value>
<value>attributes</value>
</group>
<group>
<value>attributes</value>
<value>elements</value>
</group>
<value>elements</value>
<value>attributes</value>
</choice>
</list>
</define>
<define name="actions">
<choice>
<ref name="cancelAction"/>
<group>
<zeroOrMore>
<ref name="noResultAction"/>
</zeroOrMore>
<choice>
<ref name="noResultAction"/>
<ref name="resultAction"/>
</choice>
<zeroOrMore>
<ref name="noResultAction"/>
</zeroOrMore>
</group>
</choice>
</define>
<define name="cancelAction">
<element name="cancelNestedActions">
<empty/>
</element>
</define>
<define name="noResultAction">
<choice>
<element name="validate">
<optional>
<ref name="schemaType"/>
</optional>
<zeroOrMore>
<choice>
<ref name="message"/>
<ref name="option"/>
</choice>
</zeroOrMore>
<ref name="schema"/>
<ref name="modeUsage"/>
</element>
<element>
<choice>
<name>allow</name>
<name>reject</name>
</choice>
<zeroOrMore>
<ref name="message"/>
</zeroOrMore>
<ref name="modeUsage"/>
</element>
</choice>
</define>
<define name="schema">
<choice>
<attribute name="schema">
<data type="anyURI"/>
</attribute>
<element name="schema">
<choice>
<text/>
<ref name="foreignElement"/>
</choice>
</element>
</choice>
</define>
<define name="message">
<choice>
<attribute name="message"/>
<element name="message">
<interleave>
<text/>
<attribute name="xml:lang"/>
</interleave>
</element>
</choice>
</define>
<define name="resultAction">
<element>
<choice>
<name>attach</name>
<name>attachPlaceHolder</name>
<name>unwrap</name>
</choice>
<zeroOrMore>
<ref name="message"/>
</zeroOrMore>
<ref name="modeUsage"/>
</element>
</define>
<define name="option">
<element name="option">
<attribute name="name">
<data type="anyURI"/>
</attribute>
<optional>
<attribute name="arg"/>
</optional>
<optional>
<attribute name="mustSupport">
<data type="boolean"/>
</attribute>
</optional>
</element>
</define>
<define name="modeUsage">
<optional>
<choice>
<attribute name="useMode">
<data type="NCName"/>
</attribute>
<ref name="nestedMode"/>
</choice>
</optional>
<zeroOrMore>
<element name="context">
<attribute name="path">
<ref name="path"/>
</attribute>
<optional>
<choice>
<attribute name="useMode">
<data type="NCName"/>
</attribute>
<ref name="nestedMode"/>
</choice>
</optional>
</element>
</zeroOrMore>
</define>
<define name="nestedMode">
<element name="mode">
<zeroOrMore>
<ref name="includedMode"/>
</zeroOrMore>
<zeroOrMore>
<ref name="rule"/>
</zeroOrMore>
</element>
</define>
<define name="schemaType">
<attribute name="schemaType">
<ref name="mediaType"/>
</attribute>
</define>
<define name="mediaType">
<a:documentation>5.1 of RFC 2045 allows &lt;any (US-ASCII) CHAR except SPACE, CTLs,
or tspecials&gt;, where
tspecials := "(" / ")" / "&lt;" / "&gt;" / "@" /
"," / ";" / ":" / "\" / &lt;"&gt;
"/" / "[" / "]" / "?" / "="
</a:documentation>
<data type="string">
<param name="pattern">\s*[0-9A-Za-z!#$%&amp;'\*\+\-\.\^_`\{\|\}~]*\\[0-9A-Za-z!#$%&amp;'\*\+\-\.\^_`\{\|\}~]*\s*</param>
</data>
</define>
<define name="path">
<data type="string">
<param name="pattern">\s*(/\s*)?\i\c*(\s*/\s*\i\c*)*\s*(\|\s*(/\s*)?\i\c*(\s*/\s*\i\c*)*\s*)*</param>
</data>
</define>
<define name="foreignElement">
<element>
<anyName>
<except>
<nsName/>
</except>
</anyName>
<zeroOrMore>
<attribute>
<anyName/>
</attribute>
</zeroOrMore>
<mixed>
<zeroOrMore>
<ref name="anyElement"/>
</zeroOrMore>
</mixed>
</element>
</define>
<define name="anyElement">
<element>
<anyName/>
<zeroOrMore>
<attribute>
<anyName/>
</attribute>
</zeroOrMore>
<mixed>
<zeroOrMore>
<ref name="anyElement"/>
</zeroOrMore>
</mixed>
</element>
</define>
<define name="foreignAttribute">
<attribute>
<anyName>
<except>
<nsName/>
<nsName ns=""/>
</except>
</anyName>
</attribute>
</define>
<define name="foreign">
<zeroOrMore>
<ref name="foreignAttribute"/>
</zeroOrMore>
<zeroOrMore>
<ref name="foreignElement"/>
</zeroOrMore>
</define>
</grammar>

Some files were not shown because too many files have changed in this diff Show More