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

Function document() : access to all elements (continue

Subject: Function document() : access to all elements (continued)
From: MR <mr016393@xxxxxxxxxxxxxxxxx>
Date: Wed, 11 Sep 2002 18:54:44 +0100
xsl document function
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>  &#160; &#160;  
&#160;                                                                
      <i> ( <xsl:value-of select="$dato/@nombook"/> )</i> &#160;      
&#160;                                                                
        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>  &#160;      
&#160; &#160;                                                         
        <i>  ( <xsl:value-of select="$dato/@idbook"/> )</i> &#160;    
&#160;                                                                
        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

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.