hi,
i want to generate a xml site navigation structure from a file that
shows the physical data-structure.
<?xml version="1.0"?>
<site xmlns:site="http://limpens.com/site">
<site:document-base>file:///D:/usr/jan/My Documents/Visual Studio
Projects/Limpens.com/Web/Data</site:document-base>
<site:root-document>
<site:xml-document>/BlogCollection.xml</site:xml-document>
<site:children>
<site:document>
<site:xml-Document>/IllustrationBlog.xml</site:xml-Document>
<site:children>
<site:document>
<site:xml-Document>/Illustrations/AfroBabe.xml</site:xml-Document>
</site:document>
<site:document>
<site:xml-Document>/Illustrations/ClubFlyers.xml</site:xml-Document>
</site:document>
<site:document>
<site:xml-Document>/Illustrations/iEditoraComics.xml</site:xml-Document>
</site:document>
</site:children>
</site:document>
<site:document>
<site:xml-Document>/PublicationBlog.xml</site:xml-Document>
</site:document>
<site:document>
<site:xml-Document>/DevelopmentBlog.xml</site:xml-Document>
</site:document>
</site:children>
</site:root-document>
</site>
i want to generate
<site>
<homepage>
<link>/blogcollection</link>
<title>foo</title>
<description>bar</description>
<children>
<document>
<link>/blogcollection/illustrationblog</link>
<title>illustrations</illustrations>
<description>...</description>
<children>
......
</children>
</document>
</children>
</homepage>
</site>
the title and description elements are generated by document() calls
to the said xml documents, which have many different structures, some
have schemas and namespaces, some don't.
so I thought I create this
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lc="http://limpens.com/blogbase"
xmlns:site="http://limpens.com/site">
<!-- I include the namespaces here -->
<xsl:template match="/">
<xsl:apply-templates select="//site:root-document"/>
</xsl:template>
<xsl:template match="site:root-document">
<xsl:variable name="path"
select="concat(/site/site:document-base[1],site:xml-document)"/>
<xsl:variable name="my-node" select="document($path)" />
<xsl:apply-templates select="$my-node::*" />
</xsl:template>
<xsl:template match="BlogCollection">BlogCollection!
<!-- blogcollection has no namespace, I wonder if this will work at
all... -->
</xsl:template>
<!-- and other templates for other root nodes I might encounter -->
</xsl:stylesheet>
First big question: Is this the right way to do this?
Second question... how do I generically select the root node?
<xsl:apply-templates select="$my-node::*" />
does not work, I am afraid...
thanks for any help!!
--
Jan
http://www.limpens.com
Otakoo Saloon Cartoon - newest episode at http://limpens.com/oscredirect