Subject: [xsl] Function document() : access to all elements (continued) From: MR <mr016393@xxxxxxxxxxxxxxxxx> Date: Wed, 11 Sep 2002 18:54:44 +0100 |
Thanks a lot David and Michael for your comments, I modified my template with your sugestion but I still can not get what I want, in fact I still can not understand how the document function works. Sorry for sending the following code but I didn't find a better way to explain my problem. I want to output btll (titulo-btll) class=BBBB bkni (titulo-bkni) class=ZZZZ bKr (titulo-bKr) class=CCCC collection partI= btll (titulo-btll) class=BBBB partII=bkni (titulo-bkni) class=ZZZZ impact= weak collection partI= bKr (titulo-bKr) class=CCCC partII=bkni (titulo-bkni) class=ZZZZ impact= strong I would appreciate your comments. A proposal for doing this is: <!-- ****************************************************** --> <xsl:template name="ExtractInfoDoc" > <!-- ****************************************************** --> <xsl:param name="Doc_nameID" /> <xsl:variable name="docName" select="concat($Doc_nameID,'.xml')"/> <xsl:for-each select="document($docName)//*"> <br /> <br /> <b> <xsl:value-of select=".//relation/@type"/></b> <br /> <xsl:value-of select=".//relation/role/@name"/> = <xsl:variable name="ID_object" > <xsl:value-of select="document($docName)/*/object/@id"/> </xsl:variable> <xsl:call-template name="LookXMoreInfo"> <xsl:with-param name="book_nameID" select="$ID_object"/> </xsl:call-template> <br /> <xsl:value-of select=".//attribute/@name"/> = <xsl:value-of select=".//attribute/value"/> <br /> </xsl:for-each </xsl:template> this does only the first element. I was thinking to do something like (if I get the good syntax): <xsl:choose> <xsl:when test=".='relation'"> <xsl:value-of select="./@type"/></b> <xsl:value-of select="./role/@name"/> = <xsl:when> <xsl:when test=".='object'"> <xsl:call-template name="LookXMoreInfo"> <xsl:with-param name="book_nameID" select="$./@id"/> </xsl:call-template> <xsl:when> ..... </xsl:choose> The LookXMoreInfo template get the format btll (titulo-btll) class=BBBB given a parameter containing the object id e.g btll ...It works!. It uses the doument funtion and keys (code below) =========== XML file ============== <?xml version="1.0" encoding="UTF-8" standalone="no"?> <content> <object type="book" id="btll"/> <object type="book" id="bkni"/> <object type="book" id="bKr"/> <relation type="collection"> <role name="partI"> <object type="book" id="btll"/> </role> <role name="partII"> <object type="book" id="bkni"/> </role> <attribute name="impact"><value>weak</value></attribute> </relation> <relation type="collection"> <role name="partI"> <object type="book" id="bKr"/> </role> <role name="partII"> <object type="book" id="bkni"/> </role> <attribute name="impact"><value>strong</value></attribute> </relation> </content> <!-- ****************************************************** --> <xsl:template name="LookXMoreInfo"> <!-- ****************************************************** --> <xsl:param name="book_nameID" /> <xsl:for-each select="$bookNamesFile"> <xsl:choose> <xsl:when test="key('book_Key', $book_nameID)"> <xsl:variable name="dato" select="key('book_Key', $book_nameID)"/> <b> <xsl:value-of select="$book_nameID"/> </b>       <i> ( <xsl:value-of select="$dato/@nombook"/> )</i>     Class= <i><xsl:value-of select="$dato/@classbook"/></i> </xsl:when> <xsl:when test="key('nombook_Key', $book_nameID)"> <xsl:variable name="dato" select="key('nombook_Key', $book_nameID)"/> <b><xsl:value-of select="$dato/@nombook"/> </b>       <i> ( <xsl:value-of select="$dato/@idbook"/> )</i>     Class= <i> <xsl:value-of select="$dato/@classbook"/></i> </xsl:when> <xsl:otherwise> <b> <xsl:value-of select="$book_nameID"/> </b> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xalan-java xslt node valu, Jason S | Thread | [xsl] performance with template and, Kimberly Hahn |
Re: [xsl] Avoid outputting newlines, Alex Polite | Date | [xsl] What is the probelem with thi, Sachidanandam E K |
Month |