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

Embedded Stylesheets + doc() to pull in data, the answ

Subject: Embedded Stylesheets + doc() to pull in data, the answer to stylesheet selection in browser
From: David Riggs <dariggs@xxxxxxxxxxxxxxx>
Date: Thu, 27 Oct 2005 10:34:23 +0900
xml embedded stylesheet
Thanks to reading Dr. Kay's most excellent _XSLT 2.0_, I found the solution to my problem, posted earlier on this list. I said:

"I have an xml dataset that I need to display in various language
translations and views, for users who can at most open a file with a
browser (in Win and Mac Classic, usually IE but sometimes Mozilla).

This is all on a local computer, and I need to set up the user so he can simply open a file in a browser, and get one of several xslt sheets to provide one of several view of the same, unchanging xml data. I do not want to ask them to edit the data file to call up a different
stylesheet, and I would much rather not ask them to shuffle various
style sheets and rename the current one to the sheet referenced in the
xml data.


That is, I need the equivalent to the simple command line function of
specifying the style sheet at run time, but using a browser. "


The answer is to have several place holder xml files which are in effect just stylesheets themselves, for the user to click on to see different views. Each xml file has the proper stylesheet embedded, and uses doc() to pull in the real xml data, a database of some size.


This allows the database xml file to be read only, and allows me to set up several stylesheets (embedded in xml with the doc() pointer) that I (or the user if he gets to that point), can easily modify and send back and forth.

As you all probably already know, but just for the beginners like me, the setup is like below example (see p. 96 of _XSLT 2.0_). The key is to point to the stylesheet using the href="#id" instead of a file name, which in turn requires that the 'mystyleid' attribute be explicitly declared to be type ID.

This works on my Mozilla 1.7. (thanks to the folks who offered other suggestions, but they did not quite fit).

David Riggs, Kyoto

-------------------

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE main [<!ATTLIST xsl:stylesheet mystyleid ID #REQUIRED>]>

<?xml-stylesheet type='text/xsl' href='#s1'?>
<main>

<xsl:stylesheet mystyleid="s1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="xsl:stylesheet" /><!-- to stop processing itself as data-->


<xsl:template match="/"> <!-- usual header html--></xsl:template>

<xsl:apply-templates select="document('onlydata.xml')/meibo/e">
<!-- the same xsl as usual-->
</xsl:apply-templates>

</xsl:stylesheet></main>

-------

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.