This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Function document() : access to all elements (continued)
- From: MR <mr016393 at messetud dot unice dot fr>
- To: XSL-List at lists dot mulberrytech dot com
- Date: Wed, 11 Sep 2002 18:54:44 +0100
- Subject: [xsl] Function document() : access to all elements (continued)
- Reply-to: xsl-list at lists dot mulberrytech dot com
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