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

HELP: XML File Problem from Cocoon SQL Transformer?

From: Patrick Soh <chsoh@must.edu.my>
Date: Wed, 28 Jan 2004 11:10:59 +0800
Message-ID: <004101c3e54c$5ab28530$d801a8c0@ITLAB21>
To: <www-svg@w3.org>
Hi, 
I use SQL Transformer to extract XML data. simple. 
My problem is that the resulting XML file have a problem. Specifically I am unable to read the data inside the rowset tags. 
I read the archives and seems like in the past, the rowset have duplicate nametags. Well, it doesn't have duplicate nametags now and just have 
<rowset xmlns="http://apache.org/cocoon/SQL/2.0">
However, the XSL file is unable to recognise the rowset tag. I deleted the "http://apache.org/cocoon/SQL/2.0" from the rowset tag and it works fine. Likewise, if I delete the rowset tag, the XSL file works fine. 
Any help much appreciated to work around. 

Below is the data file and Xsl file and sqlpage file. 
Data File 
=======
<?xml version="1.0" encoding="ISO-8859-1"?>
<page xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sql="http://apache.org/cocoon/SQL/2.0">
 <title>Hello</title>
    <resources>
       <resource type="file" href="sql-page.xml.sql">Schema</resource>
       <resource type="doc" href="userdocs/transformers/sql-transformer.html">SQL Transformer</resource>
    </resources>
 <content>
  <para>This is my first Cocoon2 page filled with sql data!</para>

   
      
  <rowset><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></rowset>

 </content>
</page>

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
XSL 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/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>

</xsl:stylesheet>
----------------------------------------------------------------------------------------------------------------------------------------
XSL File 
======
<?xml version="1.0"?>



<page xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sql="http://apache.org/cocoon/SQL/2.0">

<title>Hello</title>

<resources>

<resource type="file" href="sql-page.xml.sql">Schema</resource>

<resource type="doc" href="userdocs/transformers/sql-transformer.html">SQL Transformer</resource>

</resources>

<content>

<para>This is my first Cocoon2 page filled with sql data!</para>

<execute-query xmlns="http://apache.org/cocoon/SQL/2.0"> 

<query>

select eventdate, eventtime, roadid, locationid, tb_traffic.description, color from traffic.tb_traffic, traffic.tb_congestion_code where tb_traffic.description = tb_congestion_code.description

</query>

</execute-query>

</content>

</page>



  ----- Original Message ----- 
  From: Patrick Soh 
  To: www-svg@w3.org 
  Sent: Tuesday, January 27, 2004 4:44 PM
  Subject: Problem with Generated XML File from Cocoon SQL Statement?


  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 22:10:59 GMT

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