Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > In a DTD, how do I specify that an element contains arbitrary othermarkup?

Thread Tools

In a DTD, how do I specify that an element contains arbitrary othermarkup?

Simon Brooke
Posts: n/a
On Fri, 16 Jul 2010 09:23:08 +0000, Simon Brooke wrote:

> I maintain a DTD which is used to specify XML documents which are mostly
> marked up in the dialect specified by the DTD ('ADL'), but in which
> there are three elements whose contents are intended to be arbitrary
> XHTML 1.1.

Peter Flynn helpfully pointed me to RelaxNG, which does indeed prove a
very nice syntax for specifying a grammar (I'm using the XML syntax which
I find easier than the 'compact' syntax, but as they're interchangeable
that's preference. I see that RelaxNG has a mechanism for referencing
external documents:

I also found on W3C's website a specification - possibly out of date - of
XHTML 2.0 as a series of RelaxNG modules:

(I couldn't find anywhere these were downloadable as a zip or similar,
but I have copied and pasted into a set of working files to experiment

However, I haven't worked out how these are supposed to work together
since they clearly depend on one another but make no use either of the
'externalRef' mechanism or of the 'include' mechanism. I do note that
they make heavy use of the 'combine' mechanism.

The RelaxNG tool I'm currently using, trang, allows one input grammar
file only - it doesn't permit several input grammar files to be
specified. So I haven't yet worked out how to use multiple XHTML2 modules
together. Also, when I try trang on .rng files which contain
externalRefs, I get:

simon@gododdin:~/workspace/adl/schemas$ java -jar /home/simon/Downloads/
useful/trang-20091111/trang.jar adl-1.4.rng test.xsd
/home/simon/workspace/adl/schemas/adl-1.4.rng:1011:52: error: sorry,
externalRef is not yet supported

so I don't know whether I'm doing what I'm doing right. But what I'm
trying to do is specify that (for example) an ADL headmatter element may
contain xhtml script, link, meta and style elements, so I in the adl.rng
I have:

<grammar xmlns=""
<define name="headmatter">
<element name="headmatter">
<ref name="attlist.headmatter"/>
<externalRef href="permitted-html-head.rng"/>
<define name="attlist.headmatter" combine="interleave">

and in a separate file 'permitted-html-head.rng' I have

<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns=""

<ref name="permitted-xhtml-head" />

<define name="permitted-xhtml-head">
<element name="content">
<externalRef href="xhtml-2/xhtml-scripting.rng" />
<externalRef href="xhtml-2/xhtml-link.rng" />
<externalRef href="xhtml-2/xhtml-meta.rng" />
<externalRef href="xhtml-2/xhtml-style.rng" />

What I hope this is specifying is, e.g.:

<xhtml:link rel="stylesheet" type="text/css" href="styles.css" />
<xhtml:meta name="generator"
content="Application description language framework" />

I'd much rather not have the <adl:content> tag in there but I haven't yet
worked out a way of getting rid of it. I do specifically want to keep the
namespaces 'adl:' and 'xhtml:' distinct.

So, the questions:

Given that trang does not (yet) handle externalRefs, is there a tool I
can use which will translate a RelaxNG grammar using externalRefs into an
XSD schema?

And, generally, am I on the right lines?


;; Semper in faecibus sumus, sole profundam variat

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
specify arbitrary library directory directly in code? Python 1 10-28-2005 01:24 AM
calling an arbitrary function w/ arbitrary arguments Honestmath C++ 5 12-13-2004 06:18 AM
Schema: specify that element contains XML snippet ian mayo XML 2 08-11-2003 12:26 PM