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

selecting a document()'s root node

Subject: selecting a document()'s root node
From: Jan Limpens <jan.limpens@xxxxxxxxx>
Date: Wed, 10 Nov 2004 12:20:54 -0200
xml select root node
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

Current Thread

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.