[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Re: inheritance and encapsulation in xslt? / xslt

Subject: RE: Re: inheritance and encapsulation in xslt? / xslt for xlink?
From: cknell@xxxxxxxxxx
Date: Mon, 21 Jul 2003 15:08:52 -0400
inheritance examples
I think you would be better off if you let your readers judge the character of your question. "QUICK SIMPLE QUESTION" appears to be off the mark.

While there are several academic types who haunt the list, I suspect that most of us are more craftsmen than engineers.

I had to go the W3C to decipher your question, from the XLink pages (http://www.w3.org/TR/xlink/#N854):

"a resource is any addressable unit of information or service"
"The means used for addressing a resource is a URI"
"Information about how to traverse a pair of resources, including the direction of traversal and possibly application behavior information as well, is called an arc"

I looked for "transitive role", but could find no reference. According to doc at the URL above, a link can have a simple, extended, locator, or resource role. Is "transitive" some kind of subset of these, is it a term defined elsewhere in the spec, or is a term which is not defined in the spec?

I intuit from your question that you wish to treat some XLink elements differently than others. The special ones you say have "transitive roles". If I were looking at one, how would I recognize an arc with a transitive role?

If we assume that I can identify one when I'm looking it in the face, what next? It appears to me that you want to "sub-class" certain templates by calling on two XSLT stylesheets in a single transformation. One stylesheet will have all the templates you may need while a second one will have the "sub-classed" templates that you want to override the general-purpose templates. Is that about right?

Let's assume that I am correct, otherwise I don't have anything else to say. I advise you to investigate <xsl:include> and <xsl:import> as a means of incorporating the "sub-classed" templates. You can find an excellent expositon on this topic in chapter 3 of Michael Kay's XSLT Programmer's Reference, Second Edition.


-- Charles Knell cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Howard Stearns <stearns@xxxxxxxxxxxx>
Sent:     Mon, 21 Jul 2003 14:01:36 -0400
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re:  inheritance and encapsulation in xslt? / xslt for xlink?

Hmmm, no response.

Would anyone hazard an opinion as to whether the problem or my explanation is too difficult?

Any suggestions?

Thanks,
Howard Stearns

Howard Stearns wrote:
QUICK SIMPLE QUESTION (that could avoid all that follows, below):

Where can I find examples of stylesheets designed to key off of XLink arcs with transitive roles?


GENERAL PROBLEM:


I want to have two XML Schemas, where one specializes some (but not all) of the elements in the more general schema.

Meanwhile, I want to have two XSLT files:
One will work with instance documents of EITHER schema.
The second provides unique results for SOME of the elements in the more specific schema, while many should be transformed in the same way as corresponding elements in the general schema.


What are the general techniques for doing this? The specialized schema may define hundreds of specialized element tags for which the general XSLT behavior is unchanged, and I don't want to have to repeat the definitions from the general XSLT with gratuitous name changes for the xsl:template match attribute value.


ABSTRACT PROBLEM:


I'm looking for an architecture or methodology that allows encapsulation in that schema designers need only define those elements that are different from the general model and need not be aware of XSLT programming or existing XSLT code written for the general schema. Meanwhile, writers of XSLT code should not have to change with every change to the general XSLT or the general schema.

I want inheritance in my XSLT.


PROBLEM BACKGROUND:


XBRL (http://www.xbrl.org/) defines taxonomies (schema) for financial statement and other business reporting instance documents. Specialized taxonomies are defined by reference to more general ones using XLink and XML Schema. Links are defined with roles such as "general-special" and "whole-part", though I do not fully understand this yet.

It's a lot of work, but not intractable, to define company-specific schemas based on industry-specific schemas, which are in turn based on more generic ones. However, I'm not sure how to manage a series of XSLT that is meant work on instance documents of a large number of these taxonomies.

For the purpose of this question, let's assume that I can alter the schema files (e.g., by adding "class" attributes) but that I should try to avoid doing so.


MY BACKGROUND:


I've written a lot of XSLT (1.0), but not within the last year.
I'm more familiar with DTD than with XML Schema.
I'm new at XLink, but familiar with RDF and related concepts.
I'm very familiar with the implementation guts of OO programming languages.


POSSIBLE SOLUTIONS:


*** XSLT/XPath 2.0 makes use of XML Schema substitution groups, but:
- I'm under the impression that these can only be one level deep, not a general inheritance chain as is required here.
- I'm under the impression that most XSLT engines don't implement 2.0.


*** IBM's Darwin Information Typing Architecture (DITA) seems to be what I'm looking for. (See http://www-106.ibm.com/developerworks/xml/library/x-dita1/index.html and particularly http://www-106.ibm.com/developerworks/xml/library/x-dita2/index.html)

The technique is to define a class attribute in the DTD/schema and then write xsl:templates that match a portion of the value of the class attribute. The effect is to hand-implement a "class inheritance list" as though the schema elements were a prototype-based object-oriented language.

<!-- The DTD effectively defines something like this for a "subclass"
     element, although DITA defines a methodology to manage this less
     explicitly. -->
<!ATTLIST childClass
    class CDATA "- grandfatherClass parentClass childClass ">


<xsl:template match="*[contains(@class,' childClass ']"> <!-- Matches any element that has a class attribute that mentions childClass. This template takes precedence over one for parentClass if the parentClass template is in an included style sheet. --> <!--do something--> </xsl:template>

However, I don't think existing XBRL taxonomies are defined with something like the class attribute. Also, DITA is set up for DTD, and I imagine it could be simplified a bit when using XML Schema.

*** Maybe certain XLink arcs provide the necessary information in the existing XBRL schemas.

However, I haven't seen an XSLT example. I imagine it might be necessary to "compile" the transitive series of one-level parent/child class role information into a linearized "class inheritance list" attribute -- perhaps by making a separate pass with an XSLT spreadsheet to produce the "compile time" relationships and which then drives the next step of DITA-like XSLT processing.

[When I last looked at XSLT processors, they didn't seem to support XML schema very well. Is this still true?]

*** As I posed the problem, I said that I wanted to have easily maintainable general and specific XML schema files (two files) and general and specific XSLT files (two more files) that are used directly. Maybe it would be better to use XSLT and these four files to automatically produce a problem-specific XSLT file (and perhaps a problem-specific XML Schema) in which all the implicitly defined combinations have been automatically generated.

This feels like a kluge to me, might produce very big files, and might be difficult to use consistently and correctly. It's like using different programs for the different passes of a compiler and leaving the intermediate files laying around.

- Thanks in advance,
- Howard


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






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





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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.