|
Subject: RE: [xsl] Generate Yahoo-like directory structure From: "Michael Kay" <mhk@xxxxxxxxx> Date: Tue, 11 May 2004 17:44:23 +0100 |
Much easier in 2.0: use tokenize() to split the path into a sequence of
names, then use a recursive function:
<xsl:function name="f:probe" as="node()*">
<xsl:param name="origin" as="node()*/>
<xsl:param name="path" as="xs:string*"/>
<xsl:sequence select="if (empty($path))
then $origin
else f:probe($origin/element[@name=$path[1]],
remove($path,1))"/>
</xsl:function>
<xsl:param name="path" as="xs:string" required="yes"/>
<xsl:template match="/">
<xsl:copy-of select="f:probe(., tokenize($path, '/'))"/>
</xsl:template>
In 1.0 you can use similar logic but it will be much more verbose, and
you'll have to output the copied subtree from the innermost level of
call-template rather than from the outermost template as here.
Michael Kay
> -----Original Message-----
> From: Philipp Burkert [mailto:mailings@xxxxxxxxxx]
> Sent: 11 May 2004 14:53
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Generate Yahoo-like directory structure
>
> Hej folks,
>
> I am sorry, if this has been asked before, but I did research
> on the FAQ and
> the mailing list archive and could not find any information.
> It would be
> nice if someone could help me or give me a link to a thread
> where it has
> been discussed.
>
> My target is to build a HTML based yahoo-like directory
> structure out of a
> single XML file. The file looks somewhat like this.
>
> <element name="Main">
> <element name="Business">
> <element name="Finance"/>
> </element>
> <element name="Computers">
> <element name="Internet"/>
> <element name="WWW">
> <element name="Chat"/>
> <element name="DNS"/>
> </element>
> </element>
> <element name="Business"/>
> </element>
>
> As a XSL param I could offer a path like "Main/Business/"
> that identifies
> the page that should be generated. The page to be generated
> should contain
> all subelements to the "Business" element and a list of
> parent elements that
> can be used to generate a Navigation menue. (In this case
> only finance, of
> course.)
>
> This task looks so common I really wonder why I can not find anything
> online. Thankx for your help in advance.
>
> Best Regards
>
> PHILIPP BURKERT
> mailings@xxxxxxxxxx
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Generate Yahoo-like directory, Philipp Burkert | Thread | RE: [xsl] Generate Yahoo-like direc, Philipp Burkert |
| RE: [xsl] Simple XSL but having pro, Dylan Barber | Date | Re: [xsl] Highlighting, Mark Williams |
| Month |