Page 1 of 1

XHTML Inclusion impossible

Posted: Thu Jul 12, 2007 6:39 pm
by cefn
If you employ the external declaration of element contents, as outlined in the RelaxNG tutorial...
http://relaxng.org/compact-tutorial-20030326.html
...then it causes an unspecified oNDL syntax error.

Indeed there is apparently no way to specify that an element defined via a RelaxNG compact syntax should include XHTML content. So any ideas would be welcomed.

This is my original RelaxNG file, which references the html-basic schema in place inside a Jing distribution.

default namespace = "http://cefn.com/blog/"
namespace rng = "http://relaxng.org/ns/structure/1.0"
namespace xhtml = "http://www.w3.org/1999/xhtml"
datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"

grammar {

start = source

source = element source {
(post | page | source)* |
attribute uri {xsd:anyURI}
}

post = element post {
labelling, journalling, external "../lib/java/jing/jing-20030619/doc/xhtml/xhtml-basic.rng"
}

page = element page {
labelling, journalling, external "../lib/java/jing/jing-20030619/doc/xhtml/xhtml-basic.rng"
}

file = element file {
labelling, attaching
}

labelling = attribute name { xsd:IDREF}?, attribute title { xsd:string}, attribute description { xsd:string}?

journalling = attribute created { xsd:date}, attribute published { xsd:date}?

attaching = attribute bytes { xsd:base64Binary }, attribute mimetype { xsd:string }

}

Posted: Thu Jul 12, 2007 10:05 pm
by george
Hi,

You have a compact schema and you are trying to make an external reference to another grammar, but those files contain Relax NG schemas in XML form. You cannot mix Relax NG compact with XML. For instance if you place the below schema in a file in the same folder as the XHTML schema then it should be valid:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="http://cefn.com/blog/" xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="source"/>
</start>
<define name="source">
<element name="source">
<choice>
<zeroOrMore>
<choice>
<ref name="post"/>
<ref name="page"/>
<ref name="source"/>
</choice>
</zeroOrMore>
<attribute name="uri">
<data type="anyURI"/>
</attribute>
</choice>
</element>
</define>
<define name="post">
<element name="post">
<ref name="labelling"/>
<ref name="journalling"/>
<externalRef href="xhtml-basic.rng"/>
</element>
</define>

<define name="page">
<element name="page">
<ref name="labelling"/>
<ref name="journalling"/>
<externalRef href="xhtml-basic.rng"/>
</element>
</define>
<define name="file">
<element name="file">
<ref name="labelling"/>
<ref name="attaching"/>
</element>
</define>
<define name="labelling">
<optional>
<attribute name="name">
<data type="IDREF"/>
</attribute>
</optional>
<attribute name="title">
<data type="string"/>
</attribute>
<optional>
<attribute name="description">
<data type="string"/>
</attribute>
</optional>
</define>
<define name="journalling">
<attribute name="created">
<data type="date"/>
</attribute>
<optional>
<attribute name="published">
<data type="date"/>
</attribute>
</optional>
</define>
<define name="attaching">
<attribute name="bytes">
<data type="base64Binary"/>
</attribute>
<attribute name="mimetype">
<data type="string"/>
</attribute>
</define>
</grammar>
Best Regards,
George

No Compatc Syntax

Posted: Fri Jul 13, 2007 1:16 am
by cefn
So it looks like I can't use the compact syntax at all. Or is there a way to maintain this information in the compact syntax, but export through trang somehow to produce an XML file which Oxygen will put up with.

I've been putting all this work in so I could use the compact syntax, you see - it was fully specified in XSD before.

OK found a fix

Posted: Fri Jul 13, 2007 1:34 am
by cefn
Did it the other way round using trang translation from compact to xml then back again.

Exported the compact syntax to XML, then added the declaration as you suggested in the XML example, then re-exported to compact.

Then it generated all the compact syntax equivalents of the original imports - the full set of xhtml rng schemata from jing in compact form.

Here's the ant build I used for the two steps...

<target name="rngcompact2xml">
<java jar="lib/java/trang/trang.jar" fork="true">
<arg file="forms/blog.rnc"/>
<arg file="forms/blog.rng"/>
</java>
</target>

<target name="rngxml2compact">
<java jar="lib/java/trang/trang.jar" fork="true">
<arg file="forms/blog.rng"/>
<arg file="forms/blog.rnc"/>
</java>
</target>

...plus an edit in between to add the following element in place of the original element declaration for xhtml elements...

<externalRef href="../lib/java/jing/jing-20030619/doc/xhtml/xhtml.rng"/>