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

Re: Question regarding model-view architecture.


document view architecture
At 2004-01-29 15:54 +0530, Renji Panicker wrote:
>Let's say I create an XML document, say, test.xml and link it to an xsl 
>file called test.xsl,

I'm assuming you've just used stylesheet association to do so.

>now if I access the xml document, it renders the data using that xsl. So 
>far so good.

Fine ... by linking you've explicitly given the recipient the *option* of 
considering the linked stylesheet as a view of the content.

>My question is: this means I cannot apply different views to the same 
>document. Is that right?

That depends on your tool.  Saxon gives you the choice of respecting 
stylesheet association, or ignoring it.  XT never looks at stylesheet 
association.  If you choose to use Internet Explorer as the tool, you 
cannot stop having stylesheet association being followed.

The issue is addressed by the tools that you use, not by the correctness of 
what you have done in your XML.

>I know this can be done using server-side scripting, but if I have only 
>static XML (and XSL) documents, do I have any options?

Options for what?  Giving the user the run-time choice of stylesheets when 
using more than one association processing instruction?  Or having common 
content available to two stylesheets in a static environment?

The answer to the first is to use a tool that gives that option to the user 
(I don't know of one ... does anyone on the list know of a user agent that 
will detect multiple <?xml-stylesheet?> processing instructions and give 
the user the choice of which one to engage?  If so, please post!).

One answer to the second is using externally parsed general entities and 
separate "shell" documents.

An example is below ... common content is found in "test.xml".  Two shell 
instances, each one with different associated stylesheets, each refer to 
the common content by reference using an external parsed general 
entity.  I've demonstrated this using a tool that gives me the option of 
respecting stylesheet association (Saxon) and engaged it as such in both cases.

You can see the common content is captured only once in the system, yet is 
transformed two different ways.  Your end user then need only access the 
shell document with the desired associated stylesheet, and the tool will 
access the common content through that shell.

I hope this helps.

............................. Ken

T:\ftemp>type test.xml
<a><b>content here</b></a>

T:\ftemp>type test1.xml
<?xml-stylesheet type="text/xsl" href="test1.xsl"?>
<!DOCTYPE x [
<!ENTITY content SYSTEM "test.xml">
]>
<x>&content;</x>

T:\ftemp>type test2.xml
<?xml-stylesheet type="text/xsl" href="test2.xsl"?>
<!DOCTYPE x [
<!ENTITY content SYSTEM "test.xml">
]>
<x>&content;</x>

T:\ftemp>type test1.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 version="1.0">

<xsl:template match="/">
   Test 1: <xsl:value-of select="//b"/>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>type test2.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 version="1.0">

<xsl:template match="/">
   Test 2: <xsl:value-of select="//b"/>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>saxon -a test1.xml
<?xml version="1.0" encoding="utf-8"?>
   Test 1: content here
T:\ftemp>saxon -a test2.xml
<?xml version="1.0" encoding="utf-8"?>
   Test 2: content here
T:\ftemp>


--
Public courses: sign up for one or both soon to reserve your seat!
Each week:  Monday-Wednesday: XSLT/XPath;  Thursday-Friday: XSL-FO
Washington, DC: 2004-03-15           San Francisco, CA: 2004-03-22
Hong Kong, China: 2004-05-17           Bremen, Germany: 2004-05-24
World-wide on-site corporate, government & user group XML training

G. Ken Holman                 mailto:gkholman@C...
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/x/bc


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.