Search

Hi.

Is there a way to parse in page.xsl other XML beside what Symphony offers?

Let's say I have a document containing days of the week like this.

Is it mandatory to build a DS with XML source set to this file?

You could create a static XML datasource for this. Or a dynamic datasource and point it to the URL of this file, but that's a little overhead if you ask me.

Unfortunately, there is no datasource which you can point to a specific local file on your server. However, it's not that hard to alter a static XML-datasource with a simple PHP file_get_contents()-command.

I have to use the names of the weekdays with JS in n languages, depending on current language.
The names are stored in dates_en.xml, dates_ro.xml etc like this format.
I thought I could instantiate a JS array containing the names from XSL (after generating with a dynamic XML DS) and then use it.

What would you do in this situation? Would you use XML parser under JS?

What about using the XSLT document() function? Like in the Currency Converter utility.

I would use one XML and do like:

<calendar lang="en">
    ...(day/month names in English)...
</calendar>
<calender lang="ro">
    ...(day/month names in Romanian)...
</calendar>

I don't know however how many languages you have, cause otherwise it might be a huge XML. If you only have a few, I would keep it in one XML-file.

You can use the document() function in XSLT to import local XML documents. In fact you can also use it to import remote documents, but with the disadvantage of no caching, or the whole document might bomb out if the XML can't be retrieved (unlike a Dynamic XML data source).

Using the months list above, if you wanted to apply a template to the countries you could use:

<xsl:apply-templates select="document('dates_en.xml')/calendar/months/month" />

You might need to play around with the path a little bit (e.g. ../../dates_en.xml) depending on where your XML sits in relation to the XSL file.

But really "the Symphony way" is to use a Dynamic XML data source, so all of your XML fetching is consistent, and visible in the ?debug view.

@klaftertief, @vladG: I think klaftertief's method is best. Never heard of the document()-function before! :-P

@klaftertief, @nickdunn

Great tip.

@everybody

Thanks for the support.

OT: This forum needs some synchronous features ;-)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details