W3C home > Mailing lists > Public > www-svg@w3.org > January 2004

Problem with Generated XML File from Cocoon SQL Statement?

From: Patrick Soh <chsoh@must.edu.my>
Date: Tue, 27 Jan 2004 16:44:56 +0800
Message-ID: <001601c3e4b1$d7af9aa0$d801a8c0@ITLAB21>
To: <www-svg@w3.org>
Hi, 
I am a beginner with Cocoon and XML. I generated an XML File based on SQL Transformer but encounter problem when transforming that data file with XSL stylesheet. However, I do not have any problems with the XSL stylesheet transformation if I manually create the same XML data file.
Have I missed out some basic stuff? 
Your help much appreciated! 

Below is my sitemap commands and the 2 "identical" XML files and stylesheet. 

Sitemap Command
<map:match pattern="*/**">

<map:generate src="transform/sql-page.xml"/>

<map:transform type="sql">

<map:parameter name="use-connection" value="personnel"/>

<map:parameter name="clob-encoding" value="UTF-8"/>

<!--

Let's have a look at the user docs: 

"[...] The purpose of the SQLTransformer is to query a

database and translate the result to XML. [...]" 

-->

</map:transform>

<map:transform src="stylesheets/trafficdetails.xsl">

<map:parameter name="servletPath" value="{request:servletPath}"/>

<map:parameter name="sitemapURI" value="{request:sitemapURI}"/>

<map:parameter name="contextPath" value="{request:contextPath}"/>

<map:parameter name="file" value=".xml"/>

</map:transform>

<map:serialize type="xml"/>

</map:match>

XML File Generated from the Transform SQL Command 

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="trafficdetails2701.xsl"?>

<rowset xmlns="http://apache.org/cocoon/SQL/2.0">
<row>
 <eventdate>31/1/2004</eventdate>
 <eventtime>08:00</eventtime>
 <roadid>LDP</roadid>
 <locationid>LDP-BU</locationid>
 <description>BUMPER-TO-BUMPER TRAFFIC</description>
 <color>RED</color>
</row>
<row>
 <eventdate>31/1/2004</eventdate>
 <eventtime>08:00</eventtime>
 <roadid>LDP</roadid>
 <locationid>MOTOROLA</locationid>
 <description>HEAVY TRAFFIC</description>
 <color>ORANGE</color>
</row>
<row>
 <eventdate>31/1/2004</eventdate>
 <eventtime>08:00</eventtime>
 <roadid>LDP</roadid>
 <locationid>SUNWAY</locationid>
 <description>SMOOTH TRAFFIC</description>
 <color>GREEN</color>
</row>
</page>

XSL File to Transform the above XML File 

<?xml version="1.0"?>
<!-- 1st Style Sheet to convert traffic details -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:output method="xml" />

<xsl:template match="/">
<svg id="main2" viewBox="0 0 0.54729 0.366895" preserveAspectRatio="xMidYMid meet" zoomAndPan="magnify" version="1.0" contentScriptType="text/ecmascript" contentStyleType="text/css">
<g fill="none" stroke="black" stroke-width="6.11492e-005" transform="translate(0,0.366895) scale(1, -1)" xmlns:fme="http://www.safe.com/fme">
<g id="highways2" stroke-width="0.0015">
 <date> <xsl:value-of select="//page/content/rowset/row/eventdate" /> </date>
 <time>  <xsl:value-of select="//page/content/rowset/row/eventtime" /> </time>
 <xsl:variable name="loc-id"> </xsl:variable>
 <xsl:for-each select="//page/content/rowset/row">
  <use xlink:href="#{$loc-id}{locationid}" stroke="{color}"/>
 </xsl:for-each>
</g>
</g>
</svg>

</xsl:template>

Results Produced by XML and XSL File

<?xml version="1.0" encoding="UTF-16"?><svg id="main2" viewBox="0 0 0.54729 0.366895" preserveAspectRatio="xMidYMid meet" zoomAndPan="magnify" version="1.0" contentScriptType="text/ecmascript" contentStyleType="text/css" xmlns:xlink="http://www.w3.org/1999/xlink"><g fill="none" stroke="black" stroke-width="6.11492e-005" transform="translate(0,0.366895) scale(1, -1)" xmlns:fme="http://www.safe.com/fme"><g id="highways2" stroke-width="0.0015"><date></date><time></time></g></g></svg>

Note that the date, time fields are empty and locationid and color data not generated. 

Manual XML File 

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="trafficdetails2101.xsl"?>
<page xmlns:sql="http://apache.org/cocoon/SQL/2.0">

<row>
 <eventdate>19/1/2004</eventdate>
 <eventtime>17:00</eventtime>
 <roadid>LDP</roadid>
 <locationid>LDP-Sunway</locationid>
 <description>SMOOTH TRAFFIC</description>
 <color>BLUE</color>
</row>
<row>
 <eventdate>19/1/2004</eventdate>
 <eventtime>17:00</eventtime>
 <roadid>LDP</roadid>
 <locationid>LDP-Motorola</locationid>
 <description>HEAVY TRAFFIC</description>
 <color>orange</color>
</row>
<row>
 <eventdate>19/1/2004</eventdate>
 <eventtime>17:00</eventtime>
 <roadid>LDP</roadid>
 <locationid>LDP-PJ</locationid>
 <description>BUMPER-TO-BUMPER TRAFFIC</description>
 <color>red</color>
</row>
</page>

Results Produced By Manual XML File and XSL File (with minor adjustments to tags)

<?xml version="1.0" encoding="UTF-16"?><svg id="main2" viewBox="0 0 0.54729 0.366895" preserveAspectRatio="xMidYMid meet" zoomAndPan="magnify" version="1.0" contentScriptType="text/ecmascript" contentStyleType="text/css" xmlns:xlink="http://www.w3.org/1999/xlink"><g fill="none" stroke="black" stroke-width="6.11492e-005" transform="translate(0,0.366895) scale(1, -1)" xmlns:fme="http://www.safe.com/fme"><g id="highways2" stroke-width="0.0015"><date>19/1/2004</date><time>17:00</time><use xlink:href="#LDP-Sunway" stroke="BLUE" /><use xlink:href="#LDP-Motorola" stroke="orange" /><use xlink:href="#LDP-PJ" stroke="red" /></g></g></svg>

Note that the data on date, time and location id & color is generated. 








  ----- Original Message ----- 
  From: Patrick Soh 
  To: www-svg@w3.org 
  Sent: Tuesday, January 20, 2004 7:26 PM
  Subject: Help Needed: Using SVG command "use xlink:href="#local_variable_name" in XSLT


  Hi, 
  I am trying to put into XSL file the SVG command "use xlink:href="#local_variable_name" but XSL keeps rejecting it. The Error Message is "Error in input XSL: Error: Reference to undeclared namespace prefix:'xlink'. 

  The XSL works fine if I change the command to "use xlink-href="#local_variable_name" i.e. as long as I do not refer to xlink:href. 

  Attached is my xsl file and xml datafile. 

  Any help much appreciated. 

  By the way, Happy Chinese New Year to all the chinese out there!

  Patrick Soh 

  <?xml version="1.0"?>
  <!-- 1st Style Sheet to convert traffic details -->
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" />

  <xsl:template match="/">
   
  <!-- xsl:text disable-output-escaping="yes" -->

  <xsl:variable name="loc-id"> </xsl:variable>
  <!-- xsl:variable name="dtime"  / -->
  <!-- ddtime="{$dtime}{title}"></ddtime -->
  <svg xmlns="http://www.w3.org/2000/svg">
  <g>
  <date> <xsl:value-of select="//page/title" /> </date>
  <time>  <xsl:value-of select="//page/row/eventtime" />
  </time>


   <xsl:for-each select="//page/row">
    <!-- xsl:text disable-output-escaping="yes" -->
     <use xlink:href="#{$loc-id}{locationid}" stroke="{color}"/>
     <!-- /xsl:text -->
    
   </xsl:for-each>
   </g>
  </svg>
  <!-- /xsl:text -->
  </xsl:template>

  </xsl:stylesheet>

  My xml data file is 
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <?xml-stylesheet type="text/xsl" href="trafficdetails1901.xsl"?>
  <page xmlns:sql="http://apache.org/cocoon/SQL/2.0">

  <title>19/01/2004 </title>
  <row>
   <eventtime>17:00</eventtime>
   <roadid>LDP</roadid>
   <locationid>LDP-Sunway</locationid>
   <description>SMOOTH TRAFFIC</description>
   <color>BLUE</color>
  </row>
  <row>
   <eventtime>17:00</eventtime>
   <roadid>LDP</roadid>
   <locationid>LDP-Motorola</locationid>
   <description>HEAVY TRAFFIC</description>
   <color>orange</color>
  </row>
  <row>
   <eventtime>17:00</eventtime>
   <roadid>LDP</roadid>
   <locationid>LDP-PJ</locationid>
   <description>BUMPER-TO-BUMPER TRAFFIC</description>
   <color>red</color>
  </row>
  </page>
Received on Tuesday, 27 January 2004 06:40:00 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:26 GMT