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

Re: DTD/xsl:import

Subject: Re: DTD/xsl:import
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 7 Nov 2000 09:57:34 +0000
xsl importing 6 files
Maulik,

> Also in the above <!ENTITY rootdir>, I would like to formulate the string
> dynamically from a XML file using the document() function. I am not having
> toomuch luck with that either. Any help. The sample XML for that is as
> follows:
>
> <MESSAGE>
>   <CONFIG>
>     <FILES>
>      <SERVER>sdangel03</SERVER>
>      <PATH>tms</PATH>
>     </FILES>
>     <SERVLET>
>         <SERVER>jjdamukaitis01</SERVER>
>         <PORT>7001</PORT>
>     </SERVLET>
>   </CONFIG>
> </MESSAGE>

You can't dynamically generate the string that is used in an ENTITY
definition.  However, you *can* do this if, instead of using an
ENTITY, you store the string as a global variable, and then refer to
it as such.

You can store the CONFIG element from (let's say) message.xml, in a
variable using the document() function to access the root node of the
document, and an XPath to access the CONFIG element from there:

<xsl:variable name="config"
              select="document('message.xml')/MESSAGE/CONFIG" />

Now, the base URL for the files can be generated by concatenating the
FILES/SERVER and FILES/PATH together, with a '/' separator and
prefixed with 'http://':

  concat('http://', $config/FILES/SERVER, '/', $config/FILES/PATH)

If you're only accessing this information once, then you could just
use that, but otherwise it's worth putting it in a variable:

<xsl:variable name="file-base-url"
              select="concat('http://', $config/FILES/SERVER, '/',
                             $config/FILES/PATH)" />

Then, you can include this variable within your XSLT, either using:

  <xsl:value-of select="$file-base-url" />

or, if you're within an attribute, using an attribute value template:

  {$file-base-url}

In your case, for example, you can do:

<xsl:template match="/">
  ...perform some code...
  <img src="{$file-base-url}/images/name.gif" />
  <xsl:apply-templates select="//Names/Name" >
    <xsl:sort select="FN" />
  </xsl:apply-templates>
</xsl:template>

I hope that this helps,

Jeni

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



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


Current Thread
  • DTD/xsl:import
    • mxmodi - Mon, 6 Nov 2000 15:49:33 -0600
      • Mike Brown - Mon, 6 Nov 2000 16:41:42 -0700 (MST)
      • Jeni Tennison - Tue, 7 Nov 2000 09:57:34 +0000 <=

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.