relaxng / jing-trang Goto Github PK
View Code? Open in Web Editor NEWSchema validation and conversion based on RELAX NG
Home Page: http://www.thaiopensource.com/relaxng/
License: Other
Schema validation and conversion based on RELAX NG
Home Page: http://www.thaiopensource.com/relaxng/
License: Other
In HTML5 the conformance requirements for URL (e.g. the value of the href
attribute) depend on whether the character encoding of the document was
UTF-8/UTF-16 or something else.
See
http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#
terminology-0
(Yes, it's annotated as controversial, but I don't really see how the query
string issue could be addressed in another way without losing any
usefulness of validation and without losing the validity of full IRIs in
the UTF-8 case.)
Therefore, in order to implement HTML5 URL validation using a RELAX NG
datatype library, the RELAX NG validator would need to forward the
character encoding of the input document to the datatypes.
The Locator2 SAX extension provides the parser API for obtaining the
character encoding. At present, the RELAX NG datatype library interface
does not provide a way to forward this information to a datatype, so the
datatype library interface would need to be extended.
Original issue reported on code.google.com by [email protected]
on 3 Nov 2008 at 9:42
The issues described in
trang/src/com/thaiopensource/relaxng/output/dtd/todo.txt
should be entered into the issue tracker.
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 10:51
This could include other kinds of error as well, but validation errors are
the most important, because they are the ones that may be exposed to the
least technical users.
Validation errors should provide a location in terms of the element
structure of the input document.
It should be possible for applications to use the rich information to
generate their own customized error message display without having to
change any of the library code.
Applications should be able to do the localization themselves.
It should be straightforward to generate a complete XML representation of
the information, so that applications can use XSLT to generate an
appropriate presentation of the errors.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 6:00
I suggest adding a SchemaResolver interface with a single method
public Schema resolveSchema(String systemId, PropertyMap options) throws
SAXException, IOException, IncorrectSchemaException;
NVDL and NRL createChildSchema() in SchemaReceiverImpl would use this
interface instead of EntityResolver if set in the property map.
I have two uses for this interface:
1) It allows the application to maintain a cache of pre-parsed Schema
objects (at least when NVDL doesn't try to instantiate the schema with
different properties like making it an attribute schema).
2) It allows the application to provide arbitrary Java-backed
implementations of the Schema interface. In Validator.nu things like HTML
table integrity checks are implemented in Java (since schema languages
can't express the constraints) but the checker is wrapped in a Jing Schema
instance, so it can be used as if it were a schema.
Original issue reported on code.google.com by [email protected]
on 3 Nov 2008 at 11:44
Previously jing and trang could be build with GCJ. The code to do this
lives in the gcj directory. It worked by running a hairy script (gcj/dist)
which builds two .tar.gz files, which can then be built using normal Linux
build tools (both rpmbuild, autoconf, make). Although the net result is
convenient, the script is a big maintenance headache. Also I am more
interested in deb packaging (mainly for Ubuntu) rather than rpm packaging.
Also the question has to be asked of whether there is sufficient benefit to
a gcj build to make the effort worthwhile. I doubt it will run much faster.
Original issue reported on code.google.com by jjc.jclark.com
on 16 Oct 2008 at 2:16
There is a problem in PatternDumper where the ns attribute is not output on
nsName in the visitNsNameExcept method.
Index: src/com/thaiopensource/relaxng/impl/PatternDumper.java
===================================================================
--- src/com/thaiopensource/relaxng/impl/PatternDumper.java (revision 1977)
+++ src/com/thaiopensource/relaxng/impl/PatternDumper.java (working copy)
@@ -296,6 +296,7 @@
public void visitNsNameExcept(String ns, NameClass nc) {
startElement("nsName");
+ attribute("ns", ns);
startElement("except");
nc.accept(choiceNameClassVisitor);
endElement();
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 2:42
Maybe someday.
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 8:02
Currently when we have overlapping element names in interleave Jing gives
an error message saying:
overlapping element names in operands of "interleave"
but does not give any indication on what names overlap. The following patch
(from oNVDL) will provide error messages like:
overlapping element names in operands of "interleave" "y" from no namespace
for
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="root">
<interleave>
<element><anyName/><text/></element>
<element><name>y</name><text/></element>
</interleave>
</element>
</start>
</grammar>
overlapping element names in operands of "interleave" "[any name]" from no
namespace
for
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="root">
<interleave>
<element><anyName/><text/></element>
<element><nsName/><text/></element>
</interleave>
</element>
</start>
</grammar>
overlapping element names in operands of "interleave" "[any name]" from
namespace "http://test"
for
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="root">
<interleave>
<element><anyName/><text/></element>
<element><nsName ns="http://test"/><text/></element>
</interleave>
</element>
</start>
</grammar>
overlapping element names in operands of "interleave" "[any name]" from
namespace "[any namespace]"
for
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="root">
<interleave>
<element><anyName/><text/></element>
<element><anyName/><text/></element>
</interleave>
</element>
</start>
</grammar>
The patch changes the messages file to add a new parameter for the error
message and also specifies "from no namespace" when we have a name from no
namespace. It also adds a method in OverlapDetector to obtain a Name
describing the overlap and passes that Name to the
RestrictionViolationException in Alphabet. Please feel free to change the
patch, especially if you think the use of Name to pass any namespace/any
name information is not ok.
Index: src/com/thaiopensource/relaxng/impl/Alphabet.java
===================================================================
--- src/com/thaiopensource/relaxng/impl/Alphabet.java (revision 1995)
+++ src/com/thaiopensource/relaxng/impl/Alphabet.java (working copy)
@@ -22,6 +22,7 @@
if (nameClass != null
&& a.nameClass != null
&& OverlapDetector.overlap(nameClass, a.nameClass))
- throw new RestrictionViolationException("interleave_element_overlap");
+ throw new RestrictionViolationException("interleave_element_overlap",
+ OverlapDetector.getOverlappingName(nameClass, a.nameClass));
}
}
Index: src/com/thaiopensource/relaxng/impl/OverlapDetector.java
===================================================================
--- src/com/thaiopensource/relaxng/impl/OverlapDetector.java (revision 1995)
+++ src/com/thaiopensource/relaxng/impl/OverlapDetector.java (working copy)
@@ -6,7 +6,8 @@
private final NameClass nc1;
private final NameClass nc2;
private boolean overlaps = false;
-
+ private Name overlap = null;
+
private static final String IMPOSSIBLE = "\u0000";
private OverlapDetector(NameClass nc1, NameClass nc2) {
@@ -17,8 +18,10 @@
}
private void probe(Name name) {
- if (nc1.contains(name) && nc2.contains(name))
+ if (nc1.contains(name) && nc2.contains(name)) {
overlaps = true;
+ overlap = name;
+ }
}
public void visitChoice(NameClass nc1, NameClass nc2) {
@@ -65,4 +68,28 @@
}
return new OverlapDetector(nc1, nc2).overlaps;
}
+
+ static Name getOverlappingName(NameClass nc1, NameClass nc2) {
+ Name name = null;
+ if (nc2 instanceof SimpleNameClass) {
+ SimpleNameClass snc = (SimpleNameClass)nc2;
+ name = nc1.contains(snc.getName())?snc.getName():null;
+ } else
+ if (nc1 instanceof SimpleNameClass) {
+ SimpleNameClass snc = (SimpleNameClass)nc1;
+ name = nc2.contains(snc.getName())?snc.getName():null;
+ } else {
+ name = new OverlapDetector(nc1, nc2).overlap;
+ if (name != null) {
+ if (IMPOSSIBLE == name.getNamespaceUri() &&
+ IMPOSSIBLE == name.getLocalName()) {
+ name = new Name ("[any namespace]", "[any name]");
+ } else
+ if (OverlapDetector.IMPOSSIBLE == name.getLocalName()) {
+ name = new Name (name.getNamespaceUri(), "[any name]");
+ }
+ }
+ }
+ return name;
+ }
}
Index: src/com/thaiopensource/relaxng/impl/resources/Messages.properties
===================================================================
--- src/com/thaiopensource/relaxng/impl/resources/Messages.properties
(revision 1995)
+++ src/com/thaiopensource/relaxng/impl/resources/Messages.properties
(working copy)
@@ -60,7 +60,7 @@
start_contains_value=\"start\" contains \"value\"
duplicate_attribute=duplicate attribute
duplicate_attribute_detail=duplicate attribute {0}
-interleave_element_overlap=overlapping element names in operands of
\"interleave\"
+interleave_element_overlap=overlapping element names in operands of
\"interleave\" {0}
list_contains_interleave=\"list\" contains \"interleave\"
interleave_text_overlap=both operands of \"interleave\" contain \"text\"
open_name_class_not_repeated=attribute using \"nsName\" or \"anyName\"
must be in \"oneOrMore\"
@@ -98,5 +98,5 @@
first_id=first occurrence of ID \"{0}\"
# Fragments
-name_absent_namespace=\"{0}\"
+name_absent_namespace=\"{0}\" from no namespace
name_with_namespace=\"{1}\" from namespace \"{0}\"
\ No newline at end of file
Original issue reported on code.google.com by georgebina76
on 20 Oct 2008 at 10:27
At the moment we just do ID/IDREF/IDREFs.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 5:18
Converting to DTD an XML document like below
<?xml version="1.0" encoding="UTF-8"?>
<p:test xmlns:p="http://www.example.com/test">
<p:a>test</p:a>
</p:test>
gives the following DTD
<?xml encoding="UTF-8"?>
<!ELEMENT p:test (a)>
<!ATTLIST p:test
xmlns:p CDATA #FIXED 'http://www.example.com/test'>
<!ELEMENT p:a (#PCDATA)>
<!ATTLIST p:a
xmlns:p CDATA #FIXED 'http://www.example.com/test'>
The following patch fixes the problem giving as output:
<?xml encoding="UTF-8"?>
<!ELEMENT p:test (p:a)>
<!ATTLIST p:test
xmlns:p CDATA #FIXED 'http://www.example.com/test'>
<!ELEMENT p:a (#PCDATA)>
<!ATTLIST p:a
xmlns:p CDATA #FIXED 'http://www.example.com/test'>
Index:
mod/convert-dtd/src/main/com/thaiopensource/relaxng/output/dtd/DtdOutput.java
===================================================================
---
mod/convert-dtd/src/main/com/thaiopensource/relaxng/output/dtd/DtdOutput.java
(revision 2056)
+++
mod/convert-dtd/src/main/com/thaiopensource/relaxng/output/dtd/DtdOutput.java
(working copy)
@@ -164,7 +164,11 @@
class ContentModelOutput extends AbstractVisitor {
public VoidValue visitName(NameNameClass nc) {
- buf.append(nc.getLocalName());
+ String ns = nc.getNamespaceUri();
+ String prefix = null;
+ if (!ns.equals("") && !ns.equals(analysis.getDefaultNamespaceUri())
&& ns != NameClass.INHERIT_NS)
+ prefix = analysis.getPrefixForNamespaceUri(ns);
+ buf.append(prefix==null ? nc.getLocalName() : prefix + ":" +
nc.getLocalName());
return VoidValue.VOID;
}
Not sure if just using nc.getPrefix() is enough, a quick test with the
above sample XML seems to work ok. In that case the patch would be
Index:
mod/convert-dtd/src/main/com/thaiopensource/relaxng/output/dtd/DtdOutput.java
===================================================================
---
mod/convert-dtd/src/main/com/thaiopensource/relaxng/output/dtd/DtdOutput.java
(revision 2056)
+++
mod/convert-dtd/src/main/com/thaiopensource/relaxng/output/dtd/DtdOutput.java
(working copy)
@@ -164,7 +164,8 @@
class ContentModelOutput extends AbstractVisitor {
public VoidValue visitName(NameNameClass nc) {
- buf.append(nc.getLocalName());
+ String prefix = nc.getPrefix();
+ buf.append(prefix==null ? nc.getLocalName() : prefix + ":" +
nc.getLocalName());
return VoidValue.VOID;
}
Original issue reported on code.google.com by georgebina76
on 23 Oct 2008 at 3:06
I've experienced problems with the classloader-based validation back end
and datatype library autodiscovery mechanism.
1) Right now, I'm experiencing a problem with the Schematron back end
failing to be auto-discovered on Windows (Java 5 and 6) while it works on
Mac (Java 5).
2) Datatype library auto-discovery didn't work right with Java 6 on Mac
(works with Java 5 on Mac and OpenJDK 6 on Ubuntu).
3) My attempts to set a security manager to restrict file system access
broke datatype library auto-discovery.
The classloader-based autodiscovery makes sense for the binary distribution
of the command-line tool, but itโs a pain for a larger app that provides a
closed set of jars anyway.
It would be useful to have an API for turning off the auto-discovery and to
have explicit registration methods for the different factories (e.g. a
method taking a DatatypeLibraryFactory instance for registering a datatype
library).
Original issue reported on code.google.com by [email protected]
on 11 Nov 2008 at 8:15
Useful if we have large chunks of base64.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 5:33
D:\users\george\workspace\jingOnGoogle\build>type test.xml
<?xml version="1.0" encoding="UTF-8"?>
<test a="value">text</test>
D:\users\george\workspace\jingOnGoogle\build>java -jar trang.jar -I xml -O
dtd test.xml test.dtd
D:\users\george\workspace\jingOnGoogle\build>type test.dtd
<?xml encoding="UTF-8"?>
<!ELEMENT test (#PCDATA)>
<!ATTLIST test
xmlns CDATA #FIXED ''
a #REQUIRED>
Note the incorrect definition of the "a" attribute.
Original issue reported on code.google.com by georgebina76
on 24 Oct 2008 at 2:30
The following patch comes from oNVDL. It fixes an NPE in CompactSyntax that
appears when we parse a schema that uses a QName value without defining the
namespace, here it is an example of such schema:
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
namespace xsd = "http://www.w3.org/2001/XMLSchema-instance"
creator =
element creator {
(attribute scheme { xsd:QName "p:A" },
("a" | "b" | "c"))
| (attribute scheme { xsd:QName "p:B" },
("d" | "e" | "f"))
}
start = creator
Here it is the patch:
Index: src/com/thaiopensource/relaxng/parse/compact/CompactSyntax.jj
===================================================================
--- src/com/thaiopensource/relaxng/parse/compact/CompactSyntax.jj (revision
1991)
+++ src/com/thaiopensource/relaxng/parse/compact/CompactSyntax.jj (working
copy)
@@ -213,8 +213,9 @@
public String resolveNamespacePrefix(String prefix) {
String result = (String)namespaceTable.get(prefix);
- if (result.length() == 0)
+ if (result == null || result.length() == 0) {
return null;
+ }
return result;
}
Original issue reported on code.google.com by georgebina76
on 17 Oct 2008 at 6:34
D:\users\george\workspace\jingOnGoogle\build>java -jar trang.jar -I xml -O
dtd personal.xml personal.dtd
Exception in thread "main" java.util.ConcurrentModificationException
at
java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
at java.util.AbstractList$Itr.next(AbstractList.java:420)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.outputQueuedElements(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitDefine(Unknow
n
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitDefine(Unknow
n
Source)
at com.thaiopensource.relaxng.edit.DefineComponent.accept(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitContainer(Unk
nown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.topLevelOutput(Unknown Source)
at com.thaiopensource.relaxng.output.dtd.DtdOutput.output(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutputFormat.output(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.doMain(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.main(Unknown Source)
D:\users\george\workspace\jingOnGoogle\build>type personal.xml
<?xml version="1.0" encoding="UTF-8"?>
<personnel>
<person>
</person>
</personnel>
Original issue reported on code.google.com by georgebina76
on 22 Oct 2008 at 6:12
Would they have a DOCTYPE around them?
How about namespace awareness?
Have a look at DSDL Part 9.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 5:28
If I am not missing anything obvious,
com.thaiopensource.validate.nrl.SchemaImpl#createSubSchema
and
com.thaiopensource.validate.nvdl.SchemaImpl#createSubSchema
lacks facilities for entity resolution, which will break if a user ships
schemas jarred or similar.
A solution for this problem was created in EpubCheck [1] a while ago (and
the code was forked for this very reason). However, I believe a more
appropriate solution than the one implemented there would be to just hook
up any registered EntityResolver from the PropertyMap param in the
respective SchemaImpl constructor.
Attaching a diff with an outline of suggested changes.
Best regards, /Markus Gylling, DAISY Consortium
[1]
http://code.google.com/p/epubcheck/source/browse/#svn/trunk/com.adobe.epubcheck/
jingsrc
Original issue reported on code.google.com by [email protected]
on 30 Oct 2008 at 3:35
Attachments:
It would be nice if people could use Trang via a web interface without
having to download anything.
Original issue reported on code.google.com by jjc.jclark.com
on 9 Nov 2008 at 4:18
The schematron implementation currently supports version 1.5 of Schematron.
It should be updated to support the ISO version.
oNVDL has some support we can probably use.
Original issue reported on code.google.com by jjc.jclark.com
on 29 Oct 2008 at 7:09
Jing uses the regular expression engine from Xerces or the JDK in order to
implement XSD regular expressions. These engines test the input against an
NFA recursively, which may lead to stack overflows depending on the
complexity of the document being validated.
Since XSD regular expressions don't need backtracking or capturing, XSD
regular expressions could be implemented as DFAs, in which case their space
complexity would depend on the schema alone--not on the document being
validated.
There is a BSD-licensed DFA regular expression library for Java:
http://www.brics.dk/automaton/
See also http://hsivonen.iki.fi/regexp/
Original issue reported on code.google.com by [email protected]
on 3 Nov 2008 at 11:18
DtdOutput refers to messages with the following keys:
ignore_params
er.warning("ignore_params", p.getSourceLocation());
ignore_except
er.warning("ignore_except", p.getSourceLocation());
entity_name_not_ncname
er.warning("entity_name_not_ncname", entityName, inc.getSourceLocation());
while the Messages.properties file does not contain corresponding entries
leading to missing resource exceptions, for example:
C:\george\workspace\jing-trang\build>type test1.rng
<?xml version="1.0" encoding="UTF-8"?>
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<choice>
<element name="test">
<ref name="p"/>
</element>
</choice>
</start>
<define name="p">
<data type="token">
<param name="pattern">a|b</param>
</data>
</define>
</grammar>
C:\george\workspace\jing-trang\build>java -jar trang.jar -I rng -O dtd
test1.rng test1.dtd
C:\george\workspace\jing-trang\build\test1.rng:8:34: warning: approximating
datatype in content by "#PCDATA"
Exception in thread "main" java.util.MissingResourceException: Can't find
resource for bundle java.util.PropertyResource
Bundle, key ignore_params
at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
at java.util.ResourceBundle.getString(ResourceBundle.java:285)
at com.thaiopensource.util.Localizer.message(Unknown Source)
at
com.thaiopensource.relaxng.output.common.ErrorReporter.warning(Unknown Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$SimpleTypeOutput.visitData(Unkno
wn
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$SimpleTypeOutput.visitData(Unkno
wn
Source)
at com.thaiopensource.relaxng.edit.DataPattern.accept(Unknown Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.outputParamEntity(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitDefine(Unknow
n
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitDefine(Unknow
n
Source)
at com.thaiopensource.relaxng.edit.DefineComponent.accept(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitContainer(Unk
nown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.topLevelOutput(Unknown Source)
at com.thaiopensource.relaxng.output.dtd.DtdOutput.output(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutputFormat.output(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.doMain(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.main(Unknown Source)
or
C:\george\workspace\jing-trang\build>type test2.rng
<?xml version="1.0" encoding="UTF-8"?>
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<choice>
<element name="test">
<ref name="p"/>
</element>
</choice>
</start>
<define name="p">
<data type="string">
<except>
<value>a</value>
</except>
</data>
</define>
</grammar>
C:\george\workspace\jing-trang\build>java -jar trang.jar -I rng -O dtd
test2.rng test2.dtd
C:\george\workspace\jing-trang\build\test2.rng:8:34: warning: approximating
datatype in content by "#PCDATA"
Exception in thread "main" java.util.MissingResourceException: Can't find
resource for bundle java.util.PropertyResource
Bundle, key ignore_except
at java.util.ResourceBundle.getObject(ResourceBundle.java:325)
at java.util.ResourceBundle.getString(ResourceBundle.java:285)
at com.thaiopensource.util.Localizer.message(Unknown Source)
at
com.thaiopensource.relaxng.output.common.ErrorReporter.warning(Unknown Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$SimpleTypeOutput.visitData(Unkno
wn
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$SimpleTypeOutput.visitData(Unkno
wn
Source)
at com.thaiopensource.relaxng.edit.DataPattern.accept(Unknown Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.outputParamEntity(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitDefine(Unknow
n
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitDefine(Unknow
n
Source)
at com.thaiopensource.relaxng.edit.DefineComponent.accept(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitContainer(Unk
nown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.topLevelOutput(Unknown Source)
at com.thaiopensource.relaxng.output.dtd.DtdOutput.output(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutputFormat.output(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.doMain(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.main(Unknown Source)
We can add also the type as parameter in order to create a better error
message.
Original issue reported on code.google.com by georgebina76
on 27 Oct 2008 at 8:36
At the moment ID/IDREF checking is not available via the JARV interface.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 5:22
Reproducing the problem:
1. Create two .rnc files, 'library.rnc' and 'main.rnc'.
2. Include 'library.rnc' from 'main.rnc' and redefine an element which was
in 'library.rnc'.
3. Run 'trang main.rnc main.xsd'.
Problem details:
The produced 'main.xsd' file includes 'library.xsd' using the 'xs:include'
element rather than the 'xs:redefine' element. The resulting file is
therefore a malformed schema because an element is defined twice but not
correctly redefined.
A correct translation would include the file using the 'xs:redefine'
element, and include the overriding declarations inside of that element.
The defect occurs in version 20081028.
Notes:
This defect makes it very difficult to create modular schema families when
those schemas must be converted to xsd for use.
Thanks.
-Jonathon Duerig
Original issue reported on code.google.com by [email protected]
on 12 Nov 2008 at 1:16
By default, Jing currently enforces the constraints of the DTD
compatiblity spec for ID/IDREF/IDREFS datatype, and you have to use -i to
turn it off. The DTD compatibility spec has very restrictive constraints
on ambiguity which are often inconvenient. It is particularly problematic
if people (not unreasonably) declare xml:id to be of type ID: it makes no
sense at all to enforce the DTD compatibility spec for xml:id attributes,
because you can tell they are IDs just from their name.
Original issue reported on code.google.com by jjc.jclark.com
on 4 Nov 2008 at 4:32
The issues from
todo.txt
should be entered into the issue tracker. (These are for jing.)
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 11:09
com.thaiopensource.relaxng.output.XmlWriter can produce output that is not
well-formed if a comment contains characters that cannot be represented in
the encoding it is using.
The trang app currently always uses UTF-8, so I don't think this can happen
at the moment.
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 10:26
It's possible because the first non-whitespace character in a schema must
be < if the schema uses an XML syntax, but cannot be < it uses the compact
syntax.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 5:40
If the value of the attribute can't satisfy any of its candidate datatypes,
the error message(s) from the datatype(s) should be exposed in the message
emitted by the validator.
For integration with issue 31, the exception object for the bad attribute
value error should hold a set of errors emitted by the datatype(s).
Original issue reported on code.google.com by [email protected]
on 3 Nov 2008 at 11:02
The convert-from-dtd module should suppport a resolver parameter by
implementing the EntityManager interface of the dtd-parse module using
Resolver.
Original issue reported on code.google.com by jjc.jclark.com
on 3 Nov 2008 at 9:23
This issue is about the source document not the schema. There are standard
features for this, so it should be easy.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 5:17
It appears that the default ant task creates class files without line
number debugging data.
In order to more easily diagnose problems, it would be better to put
debugging data in binaries by default and leave the burden of omitting them
to those who absolutely need a minimizer jar file size.
Original issue reported on code.google.com by [email protected]
on 10 Nov 2008 at 7:30
Running Trang on the following schema gives a NPE
test.rnc:
namespace rng = "http://relaxng.org/ns/structure/1.0"
start = element rng:test { nonXMLForeignAttribute+ }
nonXMLForeignAttribute = attribute * - xml:* {text}
xmlAttribute =
attribute xml:lang { text }
| attribute xml:space { "default" | "preserve" }
| attribute xml:base { xsd:anyURI }
D:\users\george\workspace\jingOnGoogle\build>java -jar trang.jar -I rnc -O
rnc test.rnc test2.rnc
Exception in thread "main" java.lang.NullPointerException
at com.thaiopensource.relaxng.output.rnc.Output.encode(Unknown Source)
at com.thaiopensource.relaxng.output.rnc.Output.encodedText(Unknown
Source)
at com.thaiopensource.relaxng.output.rnc.Output.access$2100(Unknown
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$NameClassOutput.visitNsName(Unknown
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$NameClassOutput.visitNsName(Unknown
Source)
at com.thaiopensource.relaxng.edit.NsNameNameClass.accept(Unknown
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$NameClassOutput.visitAnyName(Unknow
n
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$NameClassOutput.visitAnyName(Unknow
n
Source)
at com.thaiopensource.relaxng.edit.AnyNameNameClass.accept(Unknown
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$PatternOutput.nameClassed(Unknown
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$PatternOutput.visitAttribute(Unknow
n
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$PatternOutput.visitAttribute(Unknow
n
Source)
at com.thaiopensource.relaxng.edit.AttributePattern.accept(Unknown
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$ComponentOutput.visitDefine(Unknown
Source)
at
com.thaiopensource.relaxng.output.rnc.Output$ComponentOutput.visitDefine(Unknown
Source)
at com.thaiopensource.relaxng.edit.DefineComponent.accept(Unknown
Source)
at com.thaiopensource.relaxng.output.rnc.Output.innerBody(Unknown
Source)
at com.thaiopensource.relaxng.output.rnc.Output.topLevel(Unknown
Source)
at com.thaiopensource.relaxng.output.rnc.Output.output(Unknown Source)
at
com.thaiopensource.relaxng.output.rnc.RncOutputFormat.outputPattern(Unknown
Source)
at
com.thaiopensource.relaxng.output.rnc.RncOutputFormat.output(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.doMain(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.main(Unknown Source)
The problem appears also when trying to convert from the equivalent RNG
schema to RNC:
<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="http://www.w3.org/XML/1998/namespace"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="rng:test">
<oneOrMore>
<ref name="nonXMLForeignAttribute"/>
</oneOrMore>
</element>
</start>
<define name="nonXMLForeignAttribute">
<attribute>
<anyName>
<except>
<nsName/>
</except>
</anyName>
</attribute>
</define>
<define name="xmlAttribute">
<choice>
<attribute name="xml:lang"/>
<attribute name="xml:space">
<choice>
<value>default</value>
<value>preserve</value>
</choice>
</attribute>
<attribute name="xml:base">
<data type="anyURI"/>
</attribute>
</choice>
</define>
</grammar>
The following patch fixes the problem:
Index:
mod/rng-schema/src/main/com/thaiopensource/relaxng/output/rnc/NamespaceManager.j
ava
===================================================================
---
mod/rng-schema/src/main/com/thaiopensource/relaxng/output/rnc/NamespaceManager.j
ava
(revision 2041)
+++
mod/rng-schema/src/main/com/thaiopensource/relaxng/output/rnc/NamespaceManager.j
ava
(working copy)
@@ -171,6 +171,7 @@
// maps namespace to preferred non-empty prefix
Map<String, String> nsMap = new HashMap<String, String>();
prefixMap.put("xml", WellKnownNamespaces.XML);
+ nsMap.put(WellKnownNamespaces.XML, "xml");
requiredNamespaces.remove(WellKnownNamespaces.XML);
List<Binding> bindingList = new Vector<Binding>();
bindingList.addAll(bindingUsageMap.keySet());
Original issue reported on code.google.com by georgebina76
on 21 Oct 2008 at 12:08
JDK 1.5 introduced the javax.xml.validation package. We should support this.
Original issue reported on code.google.com by jjc.jclark.com
on 27 Oct 2008 at 1:05
Trang preserves the file structure of the input, but if the input is spread
over multiple directories, its directory structure is lost.
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 10:15
There is an open source implementation. So it should be just a matter of
calling the resolver in the right place.
Original issue reported on code.google.com by jjc.jclark.com
on 29 Oct 2008 at 7:48
There's some stuff in trang/test/todtdtest.xml, but I'm not sure what
that's all about.
Original issue reported on code.google.com by jjc.jclark.com
on 24 Oct 2008 at 2:33
The issues described in
trang/src/com/thaiopensource/relaxng/input/xml/todo.txt
should be entered into the issue tracker.
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 10:47
Below there is a patch extracted from oNVDL that provides more information
on what required elements or attributes are missing or what is needed to
finish an element.
It contains a set of pattern functions that give the required content and a
visitor that extracts a text representation from the resulting patterns.
This needs review.
Index:
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/PatternValidator.java
===================================================================
---
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/PatternValidator.java
(revision 2167)
+++
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/PatternValidator.java
(working copy)
@@ -4,6 +4,7 @@
import com.thaiopensource.validate.Validator;
import com.thaiopensource.xml.util.Name;
import com.thaiopensource.xml.util.WellKnownNamespaces;
+import org.relaxng.datatype.Datatype;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
@@ -14,6 +15,8 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
public class PatternValidator extends DtdContext implements Validator,
ContentHandler, DTDHandler {
private final ValidatorPatternBuilder builder;
@@ -43,6 +46,421 @@
}
}
+ /**
+ * This class extracts a model string from the current pattern.
+ * The current pattern is a Relax NG pattern obtained after we derive
+ * the start pattern with the context elements and attributes.
+ *
+ * @author george
+ */
+ private static class ModelExtractorVisitor implements PatternVisitor,
NameClassVisitor {
+ // We need the following constants to avoid grouping like ((x, y), z) and
+ // have instead something like (x, y, z) which is more readable.
+ /**
+ * Constant for no grouping type.
+ */
+ private static int TYPE_NONE = 0;
+
+ /**
+ * Constant for group grouping (equivalent with sequence in XML Schema).
+ */
+ private static int TYPE_GROUP = 1;
+
+ /**
+ * Constant for choice grouping.
+ */
+ private static int TYPE_CHOICE = 2;
+
+ /**
+ * Constant for interleave grouping.
+ */
+ private static int TYPE_INTERLEAVE = 4;
+
+ /**
+ * Constant for named class choice grouping.
+ */
+ private static int TYPE_NC_CHOICE = 8;
+
+ /**
+ * The string buffer we will create the model in.
+ */
+ private StringBuffer model = new StringBuffer();
+
+ /**
+ * The current grouping type value.
+ */
+ private int type = TYPE_NONE;
+
+ /**
+ * The prefix mapping needed to solve namespaces to proxies.
+ */
+ private PrefixMapping pnm;
+
+ /**
+ * True if the content model allows elements.
+ */
+ private boolean elementAllowed;
+
+ /**
+ * True if the content model allows text.
+ */
+ private boolean textAllowed;
+
+ /**
+ * The set of attributes.
+ */
+ private Set attributes = new TreeSet();
+
+ /**
+ * Creates a model extractor visitor.
+ *
+ * @param pnm The proxy namespace mapping used to solve namespaces to
proxies.
+ */
+ public ModelExtractorVisitor(PrefixMapping pnm) {
+ this.pnm = pnm;
+ }
+
+ /**
+ * Get the model string.
+ *
+ * @return The content of the model buffer.
+ */
+ public String getModel() {
+ return model.toString();
+ }
+
+ /**
+ * Gets the detected attributes.
+ * @return The attributes set.
+ */
+ public String getAttributes() {
+ return attributes.toString();
+ }
+
+ /**
+ * Got an empty pattern.
+ *
+ * @see com.thaiopensource.relaxng.impl.PatternVisitor#visitEmpty()
+ */
+ public void visitEmpty() {
+ model.append("EMPTY");
+ }
+
+ /**
+ * Got a notAllowed pattern.
+ *
+ * @see com.thaiopensource.relaxng.impl.PatternVisitor#visitNotAllowed()
+ */
+ public void visitNotAllowed() {
+ model.append("Not allowed");
+ }
+
+ /**
+ * Got an error pattern.
+ *
+ * @see com.thaiopensource.relaxng.impl.PatternVisitor#visitError()
+ */
+ public void visitError() {
+ model.append("Error");
+ }
+
+ /**
+ * Got a group pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitGroup(com.thaiopensource.rel
axng.impl.Pattern,
com.thaiopensource.relaxng.impl.Pattern)
+ */
+ public void visitGroup(Pattern p1, Pattern p2) {
+ if (p1 instanceof EmptyPattern &&
+ p2 instanceof EmptyPattern) {
+ if (model.length() == 0) {
+ model.append("EMPTY");
+ }
+ return;
+ }
+ if (p1 instanceof EmptyPattern) {
+ p2.accept(this);
+ return;
+ }
+ if (p2 instanceof EmptyPattern) {
+ p1.accept(this);
+ return;
+ }
+ visitBinOp(p1, p2, ", ", TYPE_GROUP);
+ }
+
+ /**
+ * Got an interleave pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitInterleave(com.thaiopensourc
e.relaxng.impl.Pattern,
com.thaiopensource.relaxng.impl.Pattern)
+ */
+ public void visitInterleave(Pattern p1, Pattern p2) {
+ if (p1 instanceof EmptyPattern &&
+ p2 instanceof EmptyPattern) {
+ if (model.length() == 0) {
+ model.append("EMPTY");
+ }
+ return;
+ }
+ if (p1 instanceof EmptyPattern) {
+ p2.accept(this);
+ return;
+ }
+ if (p2 instanceof EmptyPattern) {
+ p1.accept(this);
+ return;
+ }
+ visitBinOp(p1, p2, " ^ ", TYPE_INTERLEAVE);
+ }
+
+ /**
+ * Got a choice pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitChoice(com.thaiopensource.re
laxng.impl.Pattern,
com.thaiopensource.relaxng.impl.Pattern)
+ */
+ public void visitChoice(Pattern p1, Pattern p2) {
+ if (p1 instanceof EmptyPattern &&
+ p2 instanceof EmptyPattern) {
+ if (model.length() == 0) {
+ model.append("EMPTY");
+ }
+ return;
+ }
+ visitBinOp(p1, p2, " | ", TYPE_CHOICE);
+ }
+
+ /**
+ * Handle binary grouping patterns.
+ *
+ * @param p1 The left pattern.
+ * @param p2 The right pattern.
+ * @param separator the grouping sepaator.
+ * @param pType The parent grouping pattern type.
+ */
+ private void visitBinOp(Pattern p1, Pattern p2, String separator, int
pType) {
+ int savedType = type;
+ if (pType != savedType) {
+ model.append("(");
+ type = pType;
+ }
+ p1.accept(this);
+ StringBuffer savedModel = model;
+ model = new StringBuffer();
+ p2.accept(this);
+ if (!"".equals(model.toString().replaceAll("\\)", ""))) {
+ savedModel.append(separator);
+ }
+ savedModel.append(model);
+ model = savedModel;
+ if (pType != savedType) {
+ model.append(")");
+ }
+ type = savedType;
+ }
+
+
+
+ /**
+ * Got an one or mode pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitOneOrMore(com.thaiopensource
.relaxng.impl.Pattern)
+ */
+ public void visitOneOrMore(Pattern p) {
+ if (!(p instanceof EmptyPattern)) {
+ model.append("(");
+ p.accept(this);
+ model.append(")+");
+ }
+ }
+
+ /**
+ * Got an element pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitElement(com.thaiopensource.r
elaxng.impl.NameClass,
com.thaiopensource.relaxng.impl.Pattern)
+ */
+ public void visitElement(NameClass nc, Pattern content) {
+ // just output the element name class, not the content.
+ nc.accept(this);
+ elementAllowed = true;
+ }
+
+ /**
+ * Got an attribute pattern.
+ * Here it seems we get only attribute wildcards patterns.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitAttribute(com.thaiopensource
.relaxng.impl.NameClass,
com.thaiopensource.relaxng.impl.Pattern)
+ */
+ public void visitAttribute(NameClass ns, Pattern value) {
+ model.append("@");
+ int start = model.length();
+ ns.accept(this);
+ attributes.add(model.substring(start));
+ }
+
+ /**
+ * Got a data pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitData(org.relaxng.datatype.Da
tatype)
+ */
+ public void visitData(Datatype dt) {
+ model.append("data");
+ }
+
+ /**
+ * Got a data except pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitDataExcept(org.relaxng.datat
ype.Datatype,
com.thaiopensource.relaxng.impl.Pattern)
+ */
+ public void visitDataExcept(Datatype dt, Pattern except) {
+ model.append("data");
+ }
+
+ /**
+ * Got a value pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitValue(org.relaxng.datatype.D
atatype,
java.lang.Object)
+ */
+ public void visitValue(Datatype dt, Object obj) {
+ model.append("'" + obj.toString() + "'");
+ textAllowed = true;
+ }
+
+ /**
+ * Got a text pattern.
+ *
+ * @see com.thaiopensource.relaxng.impl.PatternVisitor#visitText()
+ */
+ public void visitText() {
+ model.append("#text");
+ textAllowed = true;
+ }
+
+ /**
+ * Got a list pattern.
+ *
+ * @see
com.thaiopensource.relaxng.impl.PatternVisitor#visitList(com.thaiopensource.rela
xng.impl.Pattern)
+ */
+ public void visitList(Pattern p) {
+ model.append("list[");
+ p.accept(this);
+ model.append("]");
+ }
+
+ /**
+ * Got a choice name class.
+ *
+ * @see
com.thaiopensource.relaxng.impl.NameClassVisitor#visitChoice(com.thaiopensource.
relaxng.impl.NameClass,
com.thaiopensource.relaxng.impl.NameClass)
+ */
+ public void visitChoice(NameClass nc1, NameClass nc2) {
+ int savedType = type;
+ if (TYPE_NC_CHOICE != savedType) {
+ model.append("(");
+ type = TYPE_NC_CHOICE;
+ }
+ nc1.accept(this);
+ model.append(" | ");
+ nc2.accept(this);
+ if (TYPE_NC_CHOICE != savedType) {
+ model.append(")");
+ }
+ type = savedType;
+ }
+
+ /**
+ * Got a nsName name class.
+ *
+ * @see
com.thaiopensource.relaxng.impl.NameClassVisitor#visitNsName(java.lang.String)
+ */
+ public void visitNsName(String ns) {
+ model.append("[ns:" + ns + "]");
+ }
+
+ /**
+ * Got a nsName except name class.
+ *
+ * @see
com.thaiopensource.relaxng.impl.NameClassVisitor#visitNsNameExcept(java.lang.Str
ing,
com.thaiopensource.relaxng.impl.NameClass)
+ */
+ public void visitNsNameExcept(String ns, NameClass nc) {
+ model.append("[ns:" + ns + " \\");
+ nc.accept(this);
+ model.append("]");
+ }
+
+ /**
+ * Got an anyName nameclass.
+ *
+ * @see com.thaiopensource.relaxng.impl.NameClassVisitor#visitAnyName()
+ */
+ public void visitAnyName() {
+ model.append("[anyName]");
+
+ }
+
+ /**
+ * Got an anyName except nameclass.
+ *
+ * @see
com.thaiopensource.relaxng.impl.NameClassVisitor#visitAnyNameExcept(com.thaiopen
source.relaxng.impl.NameClass)
+ */
+ public void visitAnyNameExcept(NameClass nc) {
+ model.append("[anyName \\");
+ nc.accept(this);
+ model.append("]");
+ }
+
+ /**
+ * Got a name nameclass.
+ *
+ * @see
com.thaiopensource.relaxng.impl.NameClassVisitor#visitName(com.thaiopensource.xm
l.util.Name)
+ */
+ public void visitName(Name name) {
+ String proxy = getPrefixForNamespace(name.getNamespaceUri(), pnm);
+ if (proxy == null) {
+ model.append(name.getLocalName() + "#" + name.getNamespaceUri());
+ } else {
+ if (!"".equals(proxy)) {
+ model.append(proxy + ":");
+ }
+ model.append(name.getLocalName());
+ }
+ }
+
+ private String getPrefixForNamespace(String namespace, PrefixMapping pm) {
+ if (null == namespace || "".equals(namespace)) {
+ return "";
+ } else {
+ PrefixMapping tem = pm;
+ do {
+ if (tem.namespaceURI.equals(namespace))
+ return tem.prefix;
+ tem = tem.previous;
+ } while (tem != null);
+ return null;
+ }
+ }
+
+ /**
+ * Got a null pattern.
+ *
+ * @see com.thaiopensource.relaxng.impl.NameClassVisitor#visitNull()
+ */
+ public void visitNull() {
+ model.append("[null]");
+ }
+
+ /**
+ * @return True if child elements are allowed in the current element.
+ */
+ public boolean isElementAllowed() {
+ return elementAllowed;
+ }
+
+ /**
+ * @return True if text nodes are allowed as children of the current
element.
+ */
+ public boolean isTextAllowed() {
+ return textAllowed;
+ }
+ }
+
private void startCollectingCharacters() {
if (!collectingCharacters) {
collectingCharacters = true;
@@ -77,8 +495,12 @@
Name name = new Name(namespaceURI, localName);
if (!setMemo(memo.startTagOpenDeriv(name))) {
PatternMemo next = memo.startTagOpenRecoverDeriv(name);
- if (!next.isNotAllowed())
- error("required_elements_missing");
+ if (!next.isNotAllowed()) {
+ Pattern p = RequiredContent.getRequiredFrontierContent(builder,
memo.getPattern());
+ ModelExtractorVisitor mev = new ModelExtractorVisitor(prefixMapping);
+ p.accept(mev);
+ error("required_elements_missing", mev.getModel(), qName);
+ }
else {
next = builder.getPatternMemo(builder.makeAfter(findElement(name),
memo.getPattern()));
error(next.isNotAllowed() ? "unknown_element" :
"out_of_context_element", name);
@@ -98,7 +520,10 @@
}
if (!setMemo(memo.endAttributes())) {
// XXX should specify which attributes
- error("required_attributes_missing");
+ Pattern p = RequiredContent.getRequiredAttributes(builder,
memo.getPattern());
+ ModelExtractorVisitor mev = new ModelExtractorVisitor(prefixMapping);
+ p.accept(mev);
+ error("required_attributes_missing", mev.getAttributes(), qName);
memo = memo.ignoreMissingAttributes();
}
if (memo.getPattern().getContentType() == Pattern.DATA_CONTENT_TYPE)
@@ -140,8 +565,13 @@
PatternMemo next = memo.recoverAfter();
if (!memo.isNotAllowed()) {
if (!next.isNotAllowed()
- || fixAfter(memo).endTagDeriv().isNotAllowed())
- error("unfinished_element");
+ || fixAfter(memo).endTagDeriv().isNotAllowed()) {
+ Pattern p = RequiredContent.getRequiredContent(builder,
memo.getPattern());
+ ModelExtractorVisitor mev = new
ModelExtractorVisitor(prefixMapping);
+ p.accept(mev);
+ error("unfinished_element", mev.getModel(), qName);
+ }
+
}
memo = next;
}
@@ -234,6 +664,13 @@
hadError = true;
eh.error(new
SAXParseException(SchemaBuilderImpl.localizer.message(key, arg), locator));
}
+
+ private void error(String key, String arg, String arg1) throws
SAXException {
+ if (hadError && memo.isNotAllowed())
+ return;
+ hadError = true;
+ eh.error(new
SAXParseException(SchemaBuilderImpl.localizer.message(key, arg, arg1),
locator));
+ }
/* Return false if m is notAllowed. */
private boolean setMemo(PatternMemo m) {
Index:
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/RequiredContent.java
===================================================================
---
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/RequiredContent.java
(revision 0)
+++
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/RequiredContent.java
(revision 0)
@@ -0,0 +1,123 @@
+package com.thaiopensource.relaxng.impl;
+
+public class RequiredContent {
+ private static class RequiredContentFunction extends
AbstractPatternFunction {
+ protected final PatternBuilder spb;
+
+ RequiredContentFunction(PatternBuilder spb) {
+ this.spb = spb;
+ }
+
+ public Object caseAfter(AfterPattern p) {
+ // we get only the content, not anything after.
+ if (p.getOperand1().isNullable()) {
+ return spb.makeEmpty();
+ }
+ return p.getOperand1().applyForPattern(this);
+ }
+
+ public Object caseChoice(ChoicePattern p) {
+ if (p.isNullable()) {
+ return spb.makeEmpty();
+ } else if (p.getOperand1().isNullable()) {
+ return p.getOperand2().applyForPattern(this);
+ } else if (p.getOperand2().isNullable()) {
+ return p.getOperand1().applyForPattern(this);
+ } else {
+ return spb.makeChoice(p.getOperand1().applyForPattern(this),
+ p.getOperand2().applyForPattern(this));
+ }
+ }
+
+ public Object caseGroup(GroupPattern p) {
+ if (p.isNullable()) {
+ return spb.makeEmpty();
+ } else if (p.getOperand1().isNullable()) {
+ return p.getOperand2().applyForPattern(this);
+ } else if (p.getOperand2().isNullable()) {
+ return p.getOperand1().applyForPattern(this);
+ } else {
+ return spb.makeGroup(p.getOperand1().applyForPattern(this),
+ p.getOperand2().applyForPattern(this));
+ }
+ }
+
+ public Object caseInterleave(InterleavePattern p) {
+ if (p.isNullable()) {
+ return spb.makeEmpty();
+ } else if (p.getOperand1().isNullable()) {
+ return p.getOperand2().applyForPattern(this);
+ } else if (p.getOperand2().isNullable()) {
+ return p.getOperand1().applyForPattern(this);
+ } else {
+ return spb.makeInterleave(p.getOperand1().applyForPattern(this),
+ p.getOperand2().applyForPattern(this));
+
+ }
+ }
+
+ public Object caseOneOrMore(OneOrMorePattern p) {
+ if (p.isNullable()) {
+ return spb.makeEmpty();
+ }
+ return spb.makeOneOrMore(p.getOperand().applyForPattern(this));
+ }
+
+ public Object caseRef(RefPattern p) {
+ // not clear if we should check to avoid going into an infinite loop...
+ if (p.isNullable()) {
+ return spb.makeEmpty();
+ }
+ return p.getPattern().applyForPattern(this);
+ }
+
+ public Object caseOther(Pattern p) {
+ if (p.isNullable()) {
+ return spb.makeEmpty();
+ }
+ return p;
+ }
+ }
+
+ private static class RequiredFrontierContentFunction extends
RequiredContent.RequiredContentFunction {
+
+ RequiredFrontierContentFunction(PatternBuilder spb) {
+ super(spb);
+ }
+
+ public Object caseGroup(GroupPattern p) {
+ if (p.isNullable()) {
+ return spb.makeEmpty();
+ } else if (p.getOperand1().isNullable()) {
+ return p.getOperand2().applyForPattern(this);
+ } else {
+ return p.getOperand1().applyForPattern(this);
+ }
+ }
+ }
+
+ private static class RequiredAttributesFunction extends
RequiredContent.RequiredContentFunction {
+
+ RequiredAttributesFunction(PatternBuilder spb) {
+ super(spb);
+ }
+
+ public Object caseElement(ElementPattern p) {
+ return spb.makeEmpty();
+ }
+ }
+
+ public static Pattern getRequiredContent(PatternBuilder spb, Pattern p) {
+ return p.applyForPattern(new RequiredContentFunction(spb));
+ }
+
+ public static Pattern getRequiredFrontierContent(PatternBuilder spb,
Pattern p) {
+ return p.applyForPattern(new RequiredFrontierContentFunction(spb));
+ }
+
+ public static Pattern getRequiredAttributes(PatternBuilder spb, Pattern p) {
+ return p.applyForPattern(new RequiredAttributesFunction(spb));
+ }
+
+
+}
Index:
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/resources/Messages.pro
perties
===================================================================
---
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/resources/Messages.pro
perties
(revision 2167)
+++
mod/rng-validate/src/main/com/thaiopensource/relaxng/impl/resources/Messages.pro
perties
(working copy)
@@ -72,12 +72,12 @@
# Validation errors
unknown_element=unknown element {0}
-required_elements_missing=required elements missing
+required_elements_missing=required elements missing: \"{0}\" is expected
before element \"{1}\"
out_of_context_element=element {0} not allowed in this context
impossible_attribute_ignored=attribute {0} not allowed at this point; ignored
bad_attribute_value=bad value for attribute {0}
-required_attributes_missing=required attributes missing
-unfinished_element=unfinished element
+required_attributes_missing=\"{0}\" required attributes missing from
element \"{1}\"
+unfinished_element=unfinished element \"{1}\": \"{0}\" required to finish
the element
text_not_allowed=text not allowed here
document_incomplete=document incompletely matched
string_not_allowed=bad character content for element
Original issue reported on code.google.com by georgebina76
on 3 Nov 2008 at 1:52
The issues described in
trang/src/com/thaiopensource/relaxng/output/xsd/todo.txt
should be entered into the issue tracker (preferably with some more detail).
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 10:45
<?xml version="1.0" encoding="UTF-8"?>
<test>
<a>
<x>...</x>
</a>
<x>...</x>
</test>
D:\users\george\workspace\jingOnGoogle\build>java -jar trang.jar -I xml -O
dtd test.xml test.dtd
Exception in thread "main" java.lang.NullPointerException
at com.thaiopensource.relaxng.output.dtd.Analysis.getBody(Unknown
Source)
at com.thaiopensource.relaxng.output.dtd.DtdOutput.getBody(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$ParenthesizedContentModelOutput.
visitRef(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$ParenthesizedContentModelOutput.
visitRef(Unknown
Source)
at com.thaiopensource.relaxng.edit.RefPattern.accept(Unknown Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$ContentModelOutput.visitGroup(Un
known
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$ContentModelOutput.visitGroup(Un
known
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$TopLevelContentModelOutput.visit
Group(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$TopLevelContentModelOutput.visit
Group(Unknown
Source)
at com.thaiopensource.relaxng.edit.GroupPattern.accept(Unknown Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.outputElement(Unknown Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.outputQueuedElements(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitDefine(Unknow
n
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitDefine(Unknow
n
Source)
at com.thaiopensource.relaxng.edit.DefineComponent.accept(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput$GrammarOutput.visitContainer(Unk
nown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutput.topLevelOutput(Unknown Source)
at com.thaiopensource.relaxng.output.dtd.DtdOutput.output(Unknown
Source)
at
com.thaiopensource.relaxng.output.dtd.DtdOutputFormat.output(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.doMain(Unknown Source)
at com.thaiopensource.relaxng.translate.Driver.main(Unknown Source)
Original issue reported on code.google.com by georgebina76
on 23 Oct 2008 at 9:46
Command-line utilities should be able to act like filters.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 5:21
At the moment any JavaCC detected error just resolves in a generic "syntax
error" message. We should do better.
Original issue reported on code.google.com by jjc.jclark.com
on 7 Nov 2008 at 5:14
Should have a Trang ant task that transforms schemas like the Trang
application does.
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 10:13
The issues in
dtdinst/todo.txt
should be entered into the issue tracker.
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 11:08
Saxon 6 didn't provide column numbers for element nodes. Both Xalan and
Saxon 9.1 can provide column numbers.
I suggest using this Saxon 9.1 and Xalan feature to expose column numbers
in Schematron errors in Jing.
This has been implemented in the Validator.nu fork of oNVDL.
(svn co http://svn.versiondude.net/whattf/onvdl/trunk/ onvdl)
Original issue reported on code.google.com by [email protected]
on 3 Nov 2008 at 9:14
The issues described in
trang/src/com/thaiopensource/relaxng/input/dtd/todo.txt
should be entered into the issue tracker.
Original issue reported on code.google.com by jjc.jclark.com
on 18 Oct 2008 at 10:49
At the moment, when a RELAX NG include overrides definitions in an included
file, trang removes the overridden definitions in the generated XSD. It
would be better to keep them and leverage the XSD <redefine> feature.
Original issue reported on code.google.com by jjc.jclark.com
on 12 Nov 2008 at 2:54
Create an NVDL implementation. The NRL implementation is quite close, but
there are quite a number of significant changes. oNVDL has done the
necessary work, with the exception of inline schemas.
Original issue reported on code.google.com by jjc.jclark.com
on 29 Oct 2008 at 7:20
Primarily since the Saxon package naming changed with the release of Saxon
7 we do not have a simple way to use Saxon 7 or later in Jing.
I see two major routes:
1) Perform a brute-force update; essentially returning a Saxon7 (or later)
instance from com.thaiopensource.validate.schematron.SaxonSchemaReaderFactory.
This approach has been suggested earlier here [1], and theres an (ugly but)
running patch here [2].
2) Create two parallell SaxonSchemaReaderFactory implementations to allow
running Jing with either Saxon 6 or 7+ as the TransformerFactory provider.
Let META-INF/services/com.thaiopensource.validate.SchemaReaderFactory
namedrop both, but give precedence to the 7+ version.
Benefits of route 1:
- keeps the code cleaner.
Benefits of route 2:
- there *may* backwards incompatible behavioral changes since version 6. I
dont know of any myself (Saxon 9 on the contrary has solved problems we've
had with deadlock-like symptoms when input documents are large). Also, let
me note that the version warning issue mentioned in [1] is not relevant
since 9.0 if I recall correctly, as Mr Kay now has this turned off by
default when using the library API.
- If I am not mistaken, Saxon6 is a significantly smaller jar sizewise, a
benefit for users who are content with Saxon6 and need compact distributables.
(An alternative to route 2 would perhaps be to keep one
SaxonSchemaReaderFactory but let it discover what implementation to return
dynamically (by use of System.properties or some such). But it does make
sense to stay straight with one clean service discovery mode
(META-INF/services)).
Anyway, I'd be happy to provide patch suggestions in case you would opt to
go for route 2 (else, I believe the text in [1] should suffice).
Best regards, /Markus Gylling, DAISY Consortium
[1] http://www.oxygenxml.com/forum/post8379.html
[2]
-http://daisymfc.svn.sourceforge.net/viewvc/daisymfc/trunk/dmfc/lib/jing-saxon8-
patch.jar?view=log
-http://daisymfc.svn.sourceforge.net/viewvc/daisymfc/trunk/dmfc/src/org/daisy/ut
il/xml/validation/jaxp/SaxonSchematronSchemaReaderFactory.java?view=log
Original issue reported on code.google.com by [email protected]
on 30 Oct 2008 at 4:45
In order to make it easier for front ends to reformat messages and to
retrieve additional data based on the identity of the names in an error
message, it would be useful to have
1) a distinct subclass of SAXParseException for each RELAX NG error type
and
2) have the error object instance wrap all the variable parameters used
for formatting the message (i.e. the name of the failed element and its
parent).
This is implemented in the nu.validator.relaxng.exceptions package in the
Validator.nu fork of oNVDL.
Original issue reported on code.google.com by [email protected]
on 3 Nov 2008 at 10:55
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.