Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: SetParameter in XSL

From: "ignignokt" <davis929@-----.--->
To: NULL
Date: 2/5/2007 8:41:00 AM

Bjoern,

Thanks for your reply to my question in microsoft.public.xml.  I
actually want to run this in IE only and Im trying to teach myself XML/
XSL with limited success.  Here is the run down:

I have 2 html files(vid.html & videodb.html), 2 xml files(disc.xml &
vid.xml) and 2 xsl files(disc.xsl & vid.xsl).  Vid.html is the main
page and has 2 frames (Top frame = disc.xml and Main Frame = blank).
The Disc.xml file is transformed by Disc.xsl and will display the
titles (AVI 1, AVI 2, etc).  When you click on a specific title (ie
AVI 1), the link will send a querystring to the videodb.html file.  In
the videodb.html file, it must read the parameter passed via the
querystring(disc=AVI 2) and sort the contents of the vid.xml file
which is transformed by the vid.xsl.  The contents displayed must only
be those whose label is clicked on.

Im not sure if this makes sense or not to you, but here are my files.
In the videodb.html file, the alert brings up the correct parameter
name, but after that I need any help you can provide.  Id greatly
appreciate any sort of guidance.

vid.html:
<html>
   <head>
      <title>Video Catalog - v1.0</title>
   </head>
   <frameset rows="10%, 90%"cols="100%" border="0">
      <frame name="leftFrame" src="c:\videocatalog\config\disc.xml"
noresize="">
      <frame name="mainFrame" src="" noresize="">
   </frameset>
   <body bgcolor="#FFFFFF" text="#000000"></body>
</html>

disc.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="disc.xsl"?>
<catalog>
<disc>
<title>AVI 1</title>
</disc>
<disc>
<title>AVI 2</title>
</disc>
</catalog>

disc.xsl:
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:output method="html"/>
<xsl:template match="/">
 <html><head></head>
  <body>
   <xsl:for-each select="catalog/disc">
   <tr>
   <a target="mainFrame">
   <xsl:attribute name="href">videodb.html?disc=<xsl:value-of
select="title"/>
   </xsl:attribute>
   <xsl:value-of select = "title" />
   </a>
   </tr>
   </xsl:for-each>
    </body>
        </html>
</xsl:template>
</xsl:stylesheet>

vid.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="vid.xsl"?>
<catalog>
<disc>
<file>
<label>AVI 1</label>
<name>kurtkreisz1277.avi</name>
<size>3.13 MB</size>
<created>1/25/2007 9:13:51 AM</created>
<image01>NO IMAGE FILE</image01>
<image02>NO IMAGE FILE</image02>
<image03>NO IMAGE FILE</image03>
<image04>NO IMAGE FILE</image04>
<image05>NO IMAGE FILE</image05>
<image06>NO IMAGE FILE</image06>
</file>
<file>
<label>AVI 1</label>
<name>lagulap2.mpg</name>
<size>6.11 MB</size>
<created>1/25/2007 9:10:39 AM</created>
<image01>c:\videocatalog\images\AVI 1\lagulap201.jpg</image01>
<image02>c:\videocatalog\images\AVI 1\lagulap202.jpg</image02>
<image03>c:\videocatalog\images\AVI 1\lagulap203.jpg</image03>
<image04>c:\videocatalog\images\AVI 1\lagulap204.jpg</image04>
<image05>c:\videocatalog\images\AVI 1\lagulap205.jpg</image05>
<image06>c:\videocatalog\images\AVI 1\lagulap206.jpg</image06>
</file>
</disc>
<disc>
<file>
<label>AVI 2</label><name>tldrag.mpg</name>
<size>1.54 MB</size>
<created>1/25/2007 9:10:39 AM</created>
<image01>c:\videocatalog\images\AVI 2\tldrag01.jpg</image01>
<image02>c:\videocatalog\images\AVI 2\tldrag02.jpg</image02>
<image03>c:\videocatalog\images\AVI 2\tldrag03.jpg</image03>
<image04>c:\videocatalog\images\AVI 2\tldrag04.jpg</image04>
<image05>c:\videocatalog\images\AVI 2\tldrag05.jpg</image05>
<image06>c:\videocatalog\images\AVI 2\tldrag06.jpg</image06>
</file>
<file>
<label>AVI 2</label><name>vid1.wmv</name>
<size>1.39 MB</size>
<created>1/22/2007 9:46:28 AM</created>
<image01>c:\videocatalog\images\AVI 2\vid101.jpg</image01>
<image02>c:\videocatalog\images\AVI 2\vid102.jpg</image02>
<image03>c:\videocatalog\images\AVI 2\vid103.jpg</image03>
<image04>c:\videocatalog\images\AVI 2\vid104.jpg</image04>
<image05>c:\videocatalog\images\AVI 2\vid105.jpg</image05>
<image06>c:\videocatalog\images\AVI 2\vid106.jpg</image06>
</file
</disc>
</catalog>

vid.xsl:
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:output method="html"/>
<xsl:param name="choice" />
<xsl:template match="/">
<html>
 <body>
  <h2>
   <font face="Arial" size="6">Video Catalog v1.0</font>
  </h2>
 <xsl:if test = "$choice = 'label'">
 <xsl:for-each select="catalog/disc">
  <table width="100%" border="1">
   <tbody>
    <tr bgColor="#0033ff">
     <td width="100%">
      <font face="Arial" size="5">
      <font color="#ffffff"><strong>Disc - </strong>
      <strong><xsl:value-of select="file/label"/></strong>
      <strong><xsl:value-of select="$choice"/></strong>
      </font>
      </font>
     </td>
    </tr>
   </tbody>
  </table>
 <xsl:for-each select="file">
  <table width="100%" border="1"><tbody>
   <tr bgColor="#00ccff">
    <td><p align="center">
     <font face="Arial" size="4">
     <strong>Filename</strong>
     </font>
     </p>
    </td>
    <td>
     <p align="center">
     <font face="Arial" size="4">
     <strong>Size</strong>
     </font>
     </p>
    </td>
    <td>
     <p align="center">
     <font face="Arial" size="4">
     <strong>Date Created</strong>
     </font>
     </p>
    </td>
   </tr>
   <tr>
    <td>
     <p align="center">
     <font face="Arial">
     <xsl:value-of select="name"/>
     </font>
     </p>
    </td>
    <td>
     <p align="center">
     <font face="Arial">
     <xsl:value-of select="size"/>
     </font>
     </p>
    </td>
    <td>
     <p align="center">
     <font face="Arial">
     <xsl:value-of select="created"/>
     </font>
     </p>
    </td>
   </tr>
   <tr>
    <td><img src="{image01}"/></td>
    <td><img src="{image02}"/></td>
    <td><img src="{image03}"/></td>
    <td><img src="{image04}"/></td>
    <td><img src="{image05}"/></td>
    <td><img src="{image06}"/></td>
   </tr>
  </tbody>
 </table>
 </xsl:for-each>
 </xsl:for-each>
 </xsl:if>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

videodb.html:
<html>
 <body>
 <script type="text/javascript">
 function Request(key)
 {
  var strQueryString=QueryString();
  strQueryString=strQueryString.replace(/\%20/g," ");
  if (strQueryString.length < 1)
  return "";

  arrTmp=strQueryString.split("&");
  for (var i=0; i<arrTmp.length; i++)
  {
   var arrTmp2=arrTmp[i].split("=");
   if (arrTmp2.length < 1)
    continue;
   var curKey=arrTmp2[0];
   var curValue=(arrTmp2.length < 2)?"":arrTmp2[1];
   if (curKey.toLowerCase() == key.toLowerCase())
    return curValue;
  }
  return "";
 }
 function QueryString()
 {
  var strFullUrl=document.location+"";
  var arrTmp=strFullUrl.split("?");
  if (arrTmp.length < 2)
   return "";
  return arrTmp[1];
 }

 var discChoice = Request("disc");

 alert(discChoice);

 </script>

 </body>
</html>





transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent