Jim Bowden wrote:
> I am struggling to find the correct way to add DC metadata to our XML
> schema (my field is SGML rather than XML and I feel I am missing
> something very simple!). Following guidelines from the Dublin Core
> Metadata Initiative (http://dublincore.org/documents/usageguide/), I
> have attempted to add metadata tags as follows (the idea being that I
> can then map via XSLT all our XML files to this improved schema):
It looks as if you are trying to add an XML element called metadata (no XML
Namespace) (and the child elements from the DC XML namespace) to an XML Schema
document.
However, an XML Schema document is itself an XML document, and the structure of
that document is constrained by XML Schema's "Schema for Schemas" [1]
That schema includes an element declaration for the XML element with the
expanded name {http://www.w3.org/2001/XMLSchema, "schema"}, typically
represented using the QName xs:schema.
I was going to paste that declaration here but it's quite long and complex, so I
won't bother ;-). But (amongst other things) that declaration constrains what
child XML elements the xs:schema XML element can have - and it doesn't allow a
child element called metadata, and so an XML Schema processor which validates
the schema document rejects it as invalid.
What the DCMI document, Guidelines for implementing Dublin Core in XML [2], does
is specify an XML format for representing a DC metadata description. Let's call
that format DC-XML for convenience.
But the DCMI document says nothing about whether or how that DC-XML format can
be used in conjunction with other XML formats (e.g. the XML format which
defines an XML Schema document). The structural constraints of those other XML
formats (not defined by DCMI) condition whether or how an XML fragment
constructed according to the rules of an external XML format (like DC-XML) can
be embedded in an instance.
In the case of the XML Schema XML format, you can't embed XML elements from
another XML Namespace as children of the xs:schema element. However, the XML
Schema XML format does provide an "annotation" mechanism, which allows the
embedding of XML fragment defined using other XML formats and using names from
other XML namespaces within the xs:appinfo XML element i.e. the xs:appinfo XML
element as a "container" for the externally ndefined data.
I seem to recall I did encounter problems with some validating parsers when I
tried to use this mechanism and I'm afraid I can't point at a working example
of my own just now, but Google gives me e.g.
http://java.sun.com/webservices/docs/1.6/jaxb/vendorCustomizations.html
I think this is the mechanism you should explore to embed DC-XML fragments in
XML Schema.
So the structure of your XML schema would look something like:
<xs:schema ....>
<xs:annotation>
<xs:appinfo>
<my:dcmetadata>
<dc:title>This is my XML Schema for Widget Descriptions</dc:title>
<dc:creator>Widget MakersLtd</dc:creator>
</my:dcmetadata>
</xs:appinfo>
</xs:annotation>
</xs:schema>
Cheers
Pete
[1] http://www.w3.org/TR/xmlschema-1/#normative-schemaSchema
[2] http://dublincore.org/documents/dc-xml-guidelines/
-------
Pete Johnston
Research Officer (Interoperability)
UKOLN, University of Bath, Bath BA2 7AY, UK
tel: +44 (0)1225 383619 fax: +44 (0)1225 386838
mailto:[log in to unmask]
http://www.ukoln.ac.uk/ukoln/staff/p.johnston/
|