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

Re: Trying to load Entity file

Subject: Re: Trying to load Entity file
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 8 Nov 2000 11:04:19 +0000
xml entity file
Ken,

> I am trying to load an entity file into my XML file. The entity file
> will be located in various directories specified with a directory
> name. The directory name can be found in cookies, variables, etc...
> How can I do this?

As Mike said, XML entities are off topic for this mailing list, but
the XSLT document() function gives you another way of accessing
information in remote files, and it may be that you can use this to
your advantage.

With this method, the source XML file would hold the general
information common to all languages.  The XSLT would combine this
general information with specific information about the captions to
use in different languages.

The language to be generated on a particular run of the stylesheet can
be set using a stylesheet parameter declared at the top level of the
stylesheet with the xsl:param element:

<xsl:param name="lang" select="'en'" />

To use this technique, you need to define the captions for different
languages in XML rather than as ENTITY definitions. So, for example,
you might have a file that contains:

--- caption.xml ---
<captions xml:lang="en">
  <control id="Tab_2dControls">
    <caption>English Caption</caption>
    <caption xml:lang="fr">French Caption</caption>
    <caption xml:lang="de">German Caption</caption>
    ...
  </control>
  ...
</captions>
---

This file is accessible within an XSLT stylesheet with the function
call:

  document('caption.xml')

You can keep the node set holding these captions in a global variable
for easy access throughout your stylesheet:

<xsl:variable name="captions"
              select="document('caption.xml')/captions" />
  
Then, the caption for a particular control in a particular language
can be accessed using:

  $captions/control[@id = $control]/caption[lang($lang)]

(or, more efficiently, you could use a key to retrieve the control
that you're after).

This has the advantage of only having to maintain 2 source XML files:
one holding the common information and the other holding the
translations (you could even merge them into one if you want).  Also,
XML is a bit easier to edit than entity definitions, and more
reusable.

I hope that gives you some ideas for a different approach,

Jeni

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



 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.