Project

Profile

Help

Access to Schema / PSVI datas

Added by Anonymous almost 18 years ago

Legacy ID: #4066244 Legacy Poster: Thomas Fischer (tobasco666)

Hi, I use XML-Schemas with appinfos in declarations and type definitions. This appinfos are needed in XSL-Transformations. The appinfos has different priorities (from high to low: declaration, ref, type definition, extendet/restricted type). To have access to this appinfos I use a XSLT to detect the schema declaration and type definition for a given node in the XML data file. But this "hand-made PSVI-API" has a lot of restrictions. Now I like to switch to the schema aware Saxon, so that I have support for the full schema functionality and acces to PSVI datas. I look for a way to have access to the schema declaration and definition for a given XML node. The only functionality i have found is saxon:type-annotation to get the name of the type (if the type is global and not anonym). For my Intention its not enough - no acces to declaration, inherited types etc. Is there an other way to have access to the schema information, maybe via java extension function? And a second "academic" question: Why XSLT2/XPath2 has no mechanismen to have access to PSVI/Schema datas? Are schema appinfos obsolete? Need nobody else access to enumeration values or other schema infos in XSLT? salute Thomas


Replies (3)

Please register to reply

RE: Access to Schema / PSVI datas - Added by Anonymous almost 18 years ago

Legacy ID: #4066346 Legacy Poster: Michael Kay (mhkay)

First, as regards Saxon. If you look at the source code of saxon:type-annotation (in net.sf.saxon.functions.Extensions) it might suggest ways that you could write your own extension functions. (Though there's a path in the function "if (type==null)..." that I think is misleading: I think a SchemaType object should be returned even for anonymous types). You should be able to navigate from this to other related information. You can't get directly from an element node to the relevant element declaration because this isn't actually part of the XSLT/XQuery processing model. The XDM data model in fact contains rather less information than the PSVI (you can find the mapping in the XDM specification). In particular, when nodes are validated, the only information retained in the node is the type against which it was validated, there is no record of the element or attribute declaration. In principle you can go to the parent element, get its type annotation, and work from there, but the procedure is fairly complex. There's no standard API for access to schema information. There was an Apache Note promoting such an interface, http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040309/, and I was waiting to see whether anyone would pick this up; it doesn't seem this has happened (but perhaps I should implement it anyway). Appinfo is not currently available from the Saxon API, because Saxon simply discards this information (along with all other annotations) at schema compilation time. I'll be happy to work with users who wish to collaborate on creating a more usable capability in this area. The main thing needed is a clear understanding of what the requirements are. As regards the W3C specs: there was simply a decision made during development of this round of the specs that application access to schema information was out of scope. No doubt at the time the decision was made people were expecting the present specs to be finished in 2003 or 2004 rather than 2007, but when dates slip you can't react by allowing more functionality in. Many people would like to see this capabality (probably provided by defining an XDM representation of the schema information) but there's a lot of detailed design work needed. Michael Kay

RE: Access to Schema / PSVI datas - Added by Anonymous almost 18 years ago

Legacy ID: #4069802 Legacy Poster: Thomas Fischer (tobasco666)

Hi Michael, thanks a lot for your answer. I have two more question: Where can I find in the java sources the "mapping" from saxon:type-annotation(node as node()) to net.sf.saxon.functions.Extensions(XPathContext context, NodeInfo node) or how I can get the XPathContext? Do you will switch to Java6 in next Saxon release? salute Thomas

RE: Access to Schema / PSVI datas - Added by Anonymous almost 18 years ago

Legacy ID: #4070157 Legacy Poster: Michael Kay (mhkay)

1>Where can I find in the java sources the "mapping" from saxon:type-annotation(node as node()) to net.sf.saxon.functions.Extensions(XPathContext context, NodeInfo node) or how I can get the XPathContext? Static methods in net.sf.saxon.functions.Extensions are mapped to extension functions in the standard way, except for the use of the namespace http://saxon.sf.net/. So the method public static String typeAnnotation(XPathContext context, NodeInfo node) { is accessible as xx:type-annotation(node) in the normal way. The XPathContext parameter is supplied by the system, not by the XPath user. For more details of the mapping see http://www.saxonica.com/documentation/extensibility/functions/staticmethods.html 2>Do you will switch to Java6 in next Saxon release? I would hope that Saxon runs under Java6 today, though I haven't run any tests. I have no intention of making Saxon dependent on Java6, or even Java5, in the foreseeable future: there still seem to be many people using JDK 1.4 and I intend to keep supporting that for a while. Michael Kay

    (1-3/3)

    Please register to reply