What steps will reproduce the problem?
There seems to be some issue with validation when namespaces are used:
--8<--
<?xml version="1.0" encoding="UTF-8"?>
<rng:grammar
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns:p="some.namespace"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<rng:start>
<rng:ref name="p.p"/>
</rng:start>
<rng:define name="p.p">
<rng:element name="p:p">
<rng:text/>
</rng:element>
</rng:define>
</rng:grammar>
--8<--
<?xml version="1.0" encoding="UTF-8"?>
<p:p xmlns:p="some.namespace">Hello</p:p>
--8<---
import java.io.File;
import java.io.IOException;
import javax.annotation.Nonnull;
import javax.xml.XMLConstants;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public final class test {
public static void main(String[] args) {
System.setProperty("javax.xml.validation.SchemaFactory:"+XMLConstants.RELAXNG_NS_URI,
"com.thaiopensource.relaxng.jaxp.XMLSyntaxSchemaFactory");
// Initialise SAX parser and schema factory.
final @Nonnull SAXParserFactory parser_factory
= SAXParserFactory.newInstance();
final @Nonnull SchemaFactory schema_factory =
SchemaFactory.newInstance("http://relaxng.org/ns/structure/1.0");
final File schema_location = new File("test.rng");
try {
final @Nonnull Schema schema = schema_factory.newSchema(schema_location);
parser_factory.setNamespaceAware(true);
parser_factory.setSchema(schema);
final @Nonnull SAXParser parser = parser_factory.newSAXParser();
parser.parse("test.xml", (DefaultHandler) null);
} catch (ParserConfigurationException e) {
System.out.println(e.getMessage());
} catch (SAXException e) {
System.out.println(e.getMessage());
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
--8<---
What is the expected output? What do you see instead?
The document should validate (it does using other validators such as
xmllint, and the jing command line tool):
$ xmllint --noout --relaxng test.rng test.xml
test.xml validates
$ java -jar jing.jar test.rng test.xml
$
Instead, the java program above will raise an exception:
found attribute "xmlns:p", but no attributes allowed here
What version of the product are you using? On what operating system?
jing-20091111, openjdk 6, freebsd 8.1 amd64.
Please provide any additional information below.
Original issue reported on code.google.com by xorquew...@googlemail.com on 2 Feb 2011 at 11:02
Original issue reported on code.google.com by
xorquew...@googlemail.com
on 2 Feb 2011 at 11:02