D
Don Garrett
I have an XML document at the root of a directory tree that contains
relative URIs to resources in a directory tree.
During XSLT processing, these URI's can be used without any problems
to access the various documents in the tree. However, when generating
HTML output, the output <a href=""> tags need to be adjusted for the
location of the document that is displaying them.
I need to use relative URLs, since the documents need to be
translated in a variety of locations without modification.
file://foo/bar/resources.xml
http://server/resources.xml
http://server/foo/bar/resources.xml
resources.xml looks something like this:
<resources>
<resource>
<name>Foo</name>
<uri>subdir/foo.xml</uri>
</resource>
</resources>
I have an <xsl:template> to expand this to:
<a href="subdir/foo.xml">Foo</a>
However, I get that exact expansion, even if I am expanding a
document that is already in subdir, subdir1, or subdir2.
I would like to instead have it expand differently, depending on the
location of the document that is being expanded.
If the document is in:
subdir: <a href="foo.xml">Foo</a>
subdir2: <a href="../subdir/foo.xml">Foo</a>
subdir2/subsubdir: <a href="../../subdir/foo.xml">Foo</a>
etc.
What is the best approach to solving this problem? This is my first
large scale use of XML/XSLT, but I have a hard time believing that this
isn't a common issue.
How do other people solve this problem?
relative URIs to resources in a directory tree.
During XSLT processing, these URI's can be used without any problems
to access the various documents in the tree. However, when generating
HTML output, the output <a href=""> tags need to be adjusted for the
location of the document that is displaying them.
I need to use relative URLs, since the documents need to be
translated in a variety of locations without modification.
file://foo/bar/resources.xml
http://server/resources.xml
http://server/foo/bar/resources.xml
resources.xml looks something like this:
<resources>
<resource>
<name>Foo</name>
<uri>subdir/foo.xml</uri>
</resource>
</resources>
I have an <xsl:template> to expand this to:
<a href="subdir/foo.xml">Foo</a>
However, I get that exact expansion, even if I am expanding a
document that is already in subdir, subdir1, or subdir2.
I would like to instead have it expand differently, depending on the
location of the document that is being expanded.
If the document is in:
subdir: <a href="foo.xml">Foo</a>
subdir2: <a href="../subdir/foo.xml">Foo</a>
subdir2/subsubdir: <a href="../../subdir/foo.xml">Foo</a>
etc.
What is the best approach to solving this problem? This is my first
large scale use of XML/XSLT, but I have a hard time believing that this
isn't a common issue.
How do other people solve this problem?