xsl-list
[Top] [All Lists]

RE: [xsl] Variables

2009-10-26 07:47:08
Firstly, xsl:if doesn't change the context node, so this

    <xsl:if test="webenmr/calculation">
        <xsl:if test="webinfo">
            <xsl:value-of select="@workingdir"/>

should probably be something like this:

    <xsl:if test="webenmr/calculation">
        <xsl:if test="webemr/calculation/webinfo">
            <xsl:value-of select="webemr/calculation/webinfo/@workingdir"/>

Assuming the context node is a pdb_info, you can output your hyperlink like
this:

    <a
href="{ancestor::calculation/webinfo/@workingdir}/{(_at_)filename}">...</a>

I think you're having problems because you haven't understood the concept of
the context node/item, or the details of when and how it changes. Also: try
to take advantage of apply-templates and template rules, rather than
wrapping everying in deeply-nested for-each loops.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

 

-----Original Message-----
From: David Galligani [mailto:galligani(_at_)cerm(_dot_)unifi(_dot_)it] 
Sent: 26 October 2009 11:29
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Variables 

Hi all ,
I' m a complete newbie in xml/xsl , and I'm having several problems .
I have the following xml :

<webenmr>
<calculation>
<webinfo workingdir="x_10_2009" />
<protocol name="xplor" type="pm">
<parameter init_t="2500" high_step="10000" cool_step="10000"
end_count="5" loop_count="3" timestep="0.005" n_thread="20" 
/> <structure> <struct_file>protein.psf</struct_file>
<struct_file>CA2.psf</struct_file>
<struct_file>axis_new_501.psf</struct_file>
<struct_file>axis_new_502.psf</struct_file>
<struct_file>axis_new_503.psf</struct_file>
</structure>
<parameter_md>
<param_file>par_axis_3.pro</param_file>
<param_file>ca.par</param_file>
</parameter_md>
<coordinate>
<coord_file>protein.pdb</coord_file>
<coord_file>ca.pdb</coord_file>
<coord_file>axis_xyzo_3_501.pdb</coord_file>
<coord_file>axis_xyzo_3_502.pdb</coord_file>
<coord_file>axis_xyzo_3_503.pdb</coord_file>
</coordinate>
<noe>
    <cls name="tensor" scale="1000">
     <noe_file>tensors.tbl</noe_file>
    </cls>
    <cls name="noe" scale="50">
     <noe_file>calbindin_NOE.tbl</noe_file>
     <noe_file>metalcenter.tbl</noe_file>
    </cls>
   </noe>
   <dih>
    <dih_file>calbindin_ACO.tbl</dih_file>
   </dih>
   <xpcs xpcs_file="calbindin_PCS_ce.tbl" xclass="pcsce" t1="521.4" 
t2="-175.5" fmed="20" scale="5.0" />
   <xpcs xpcs_file="calbindin_PCS_dy.tbl" xclass="pcsdy" t1="9041.9" 
t2="-5601.7" fmed="20" scale="0.25" />
   <xpcs xpcs_file="calbindin_PCS_yb.tbl" xclass="pcsyb" t1="1978.7" 
t2="-923.3" fmed="20" scale="1.25" />
   <xrdc xrdc_file="calbindin_RDC_ce.tbl" xclass="rdcce" t1="-0.424" 
t2="0.143" fmed="20" scale="1.0" />
   <xrdc xrdc_file="calbindin_RDC_dy.tbl" xclass="rdcdy" t1="-7.348" 
t2="4.552" fmed="20" scale="0.05" />
   <xrdc xrdc_file="calbindin_RDC_yb.tbl" xclass="rdcyb" t1="-1.608" 
t2="0.750" fmed="20" scale="0.25" />
   <metal_parameter type="xml">
    <convert type="xplor,amber" />
    <type_name name="M1" element="Ca" mass="40.080" eps="0.05" />
   </metal_parameter>
   <metal_topology type="xml">
    <res name="XM1">
     <atom_name name="CA2" type_name="M1" charge="2.0" num="1" />
    </res>
   </metal_topology>
   <analysis comp_sel="name CA" top_frac="0.2" />
  </protocol>
  <output name="xplor">
   <iteration number="1">
    <pdb_info directory="./input_9/"
filename="ite_1_d_input_9_pdb_sa1_1.pdb">
<XPCS_tensor A1="554.334203883598" energy_pcs="0.958539032156901"
A2="-166.871736148801" class="pcsce"
total_energy="89.1003471455398" />
</pdb_info>
<pdb_info directory="./input_9/"
filename="ite_1_d_input_9_pdb_sa1_2.pdb">
<XPCS_tensor A1="541.035035882894" energy_pcs="1.39407060526426"
A2="-159.967740084884" class="pcsce"
total_energy="188.041801829022" />
</pdb_info>
<pdb_info directory="./input_9/"
filename="ite_1_d_input_9_pdb_sa1_3.pdb">
<XPCS_tensor A1="535.219580534061" energy_pcs="1.32367130882385"
A2="-175.784774140119" class="pcsce"
total_energy="90.7929905009074" />
</pdb_info>
[...]

and the xsl  ( which probably will be infested with errors :) ):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" encoding="UTF-8"/>

    <xsl:template match="/">
        <html>
<head>
<meta http-equiv="content-type" content="text/html; 
charset=utf-8" /> <title>ENMRWEBUI</title>


<!--<link xmlns="http://www.w3.org/1999/xhtml"; 
type="text/css" href="" />-->

<!--<link rel="stylesheet" type="text/css" media="print" 
href="css/enmrwebui.css" />-->
</head><body>
        <!--<xsl:if test="@name='xplor'">-->
            <xsl:if test="webenmr/calculation">
                <xsl:if test="webinfo">
                <xsl:value-of select="@workingdir"/>
                </xsl:if>
                 <xsl:if test="webenmr/calculation/output/iteration">
                    <table id="outputTable">
                     <xsl:for-each
select="webenmr/calculation/output/iteration">
                        <tr><th>Iteration
                            </th>
                      
                            <td>
                                <xsl:value-of select="@number"/>
                           
                            </td><td></td><td></td><td></td>

                         </tr>
             
                        <xsl:for-each select="pdb_info">
                             <tr>
                                <th>File</th>
                                <td><a href="file_pdb/">
                                   
                                    <xsl:value-of select="@filename"/>
                                    </a>
                                </td><td></td><td></td><td></td>
                             </tr>
                           
                                        <xsl:if test="XPCS_tensor">
                                <tr>
                                    <th>XPCS Tensor A1 
</th><th>Energy PCS</th><th>A2</th><th>Class</th><th>Total Energy</th>
                                </tr>
                               
                                <xsl:for-each select="XPCS_tensor">
                                   
                                <tr>
                                    <td><xsl:value-of 
select="@A1"/> </td>
                               
                                    <td> <xsl:value-of 
select="@energy_pcs"/></td>
                              
                                    <td><xsl:value-of 
select="@A2"/> </td>
                              
                                    <td><xsl:value-of 
select="@class"/></td>
                               
                                    <td> <xsl:value-of 
select="@total_energy"/></td>
                                </tr>   
                                </xsl:for-each>
                                </xsl:if>
                               [...]

I want to concatenate the "workingdir" and "filename" values 
in an hyperlink , something like <a 
href='workingdir/filename'>File</a>
but atm nothing seems to work .
I'm sure it' s a silly thing , but I have already lost 2 days 
trying to achieve it , and I was wondering if someone could help me .
Many thx in advance .

David

P.S.: I hope you can understand my english ...


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--