This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: doctype


Gerhard,

>>Another one -- use schema instead of a DTD.
> I don't see, why this would change anything at XSLT level ?

References to schemas are contained within attributes within the
source XML, so it's possible to get the location of an XML schema for
a particular XML instance with something like:

<xsl:variable name="schema-location" select="/*/@xsi:schemaLocation" />

Given that, you can access the schema itself with the document()
function:

<xsl:variable name="schema" select="document($schema-location, /)" />

Once you have hold of the XML Schema, you can theoretically find
information about the document type, such as default attribute values,
by querying into it 'by hand' from within the stylesheet.  I think
this is what Dimitre was suggesting.

Given the complexity of XML Schemas and the number of ways you can
express a particular constraint, using information from XML Schemas in
this way is pretty complex. If you have control over the schema, you
can make various simplifying assumptions that might make it
worthwhile. However, I don't think it's possible to reliably gather
the name of the document element (which is what you were after) from a
schema, given that a schema might allow multiple possible document
elements: it's much better to use the XPath 'local-name(/*)' for a
particular instance as various others suggested.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]