[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Generate Yahoo-like directory structure
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: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|