I am working with XSLT version 1.0 using xsltproc.
This is my first post; please bare with me if I've missed out on any
of the house rules. I have tried as much as possible to replicate what
I am trying to do below. My senario is as follows:
Folder Structure
folder/
|-- index.xml
|-- dir1
| |-- d1f1.xml
| |-- d1f2.xml
| |--
|-- dir2
| |-- d2f1.xml
| |-- d2f2.xml
| |--
Current XSLT stylesheet
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="utf-8" />
<xsl:template match="folder">
<xsl:apply-templates select="document(file)/file" />
</xsl:template>
<xsl:template match="file">
<name>
<xsl:value-of select="name" />
</name>
<link>
<file>document(../dir2/d2f1.xml, /)/file/name</file>
<description>document(../dir2/d2f1.xml, /)/file/description</description>
</link>
</xsl:template>
</xsl:stylesheet>
index.xml file
<?xml version="1.0" encoding="utf-8"?>
<folder name="dir1">
<file>f1.xml</file>
<file>f2.xml</file>
</folder>
d1f1.xml
<?xml version="1.0" encoding="utf-8"?>
<file>
<name>File 1</name>
<description>I am file 1</description>
<link>dir2/d2f1.xml</link>
</file>
d2f2.xml
<?xml version="1.0" encoding="utf-8"?>
<file>
<name>File 2</name>
<description>I am file 2</description>
</file>
Question# 1:
How can I keep track of the folder attribute in the parent template so
I can make use of it when calling the child templates?
Question# 2:
The potion of code below fails until I explictly provide the absolute
path and also prepend it with file://D|
this fails
<link>
<file>document(../dir2/d2f1.xml, /)/file/name</file>
<description>document(../dir2/d2f1.xml, /)/file/description</description>
</link>
this works (I stole this idea from
http://www.dpawson.co.uk/xsl/sect2/N2602.html#d3862e403)
<link>
<file>document(file://D|/home/phiri/dir2/d2f1.xml)/file/name</file>
<description>document(file://D|/home/phiri/dir2/d2f1.xml)/file/description</description>
</link>
Question# 3:
Is it possible for me to determine using XSLT the directory path of
the XML file being processed?
All sources I have found online seem to suggest its not possible to
evaluate the directory path of the XML file being processed.
--
------------------------------
Lighton Phiri
http://lightonphiri.org/
------------------------------
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--