[xslt] xsltproc port to RISC OS (and errors)



Hiya,

I've ported xsltproc (libxslt, libxml2 and the xmlproc that uses them)
to RISC OS. I don't know if this is of interest to you, but I can
provide diffs if you would like to incorporate the necessary (minor)
changes required.

In addition, I've added 'throwback' support to xsltproc. Throwback is
a system used extensively under RISC OS development tools to provide
feedback to the user on errors and warnings, appearing in clickable
lists to jump to the correct point. The manner in which I've implemented
this is not ideal, beause I must parse the error string passed to the
handler. This may, or may not, be of use to you, but is essential for
my own work with it :-)

Attached you'll find two sets of documents which I've been playing
with. The quality of these as regards xslt is questionable, but I am
only playing at present.

example.xsl & example.xml are a very cut down error presenting case.
Under RISC OS, they give :

--8<--------
*@.xsltproc -T -o t.html example.xml
example.xsl:10: error: Premature end of data in tag atch="chapter[5">
thingy
</xsl

^
xsltParseStylesheetFile : cannot parse example.xsl
xsltParseStylesheetProcess : document is not a stylesheet
--8<--------

Notice the strange error message that is displayed for this broken
tag.

template.xml, riscos-prm.xsl and riscos-prm.dtd are an example of the
same problem, intentionally introduced. Under RISC OS this gives a
more serious error :

--8<--------
*@.xsltproc -o t.html template.xml
xsltCompileStepPattern : ']' expected

*** unrecoverable error in run time system: free failed
*
--8<--------

'free failed' is the C library's way of saying 'my heap is corrupt and
therefore I can't give you any memory'. It's quite possible that I've
introduced a fault of my own in the port, BUT it might be useful to
compile with fortify to see whether what I'm seeing is endemic (the
version I use under linux works just fine, but I've not done any more
than rudimentary tests).

Anyhow, I hope that is vaguely interesting to you :-)
-- 
Gerph {djf0-.3w6e2w2.226,6q6w2q2,2.3,2m4}
URL: http://www.movspclr.co.uk/
[ All information, speculation, opinion or data within, or attached to,
  this email is private and confidential. Such content may not be
  disclosed to third parties, or a public forum, without explicit
  permission being granted. ]
<?xml version="1.00" ?>

<!-- Just some entities for the PRM DTD
     I have NOT defined a strict DTD for the PRM pages I'm working on,
     because I'm still experimenting with the presentation of the XML such
     that it is sane and human maintainable.
  -->

<!ENTITY riscos-swi-os_byte "somescheme:///SWI/OS/Byte#">
<!ENTITY riscos-swi-os_upcall "somescheme:///SWI/OS/UpCall#">
<!ENTITY riscos-swi-os_gbpb "somescheme:///SWI/OS/GBPB#">
<!ENTITY riscos-swi-os_cli "somescheme:///SWI/OS/CLI#">
<!ENTITY riscos-swi-shellcli_create "somescheme:///SWI/ShellCLI.html#swi_create">
<!ENTITY riscos-swi-shellcli_destroy "somescheme:///SWI/ShellCLI.html#swi_create">
<!ENTITY riscos-swi-wimp_starttask "somescheme:///SWI/Wimp.html#swi_starttask">
<!ENTITY riscos-command-wimptask "somescheme:///SWI/Wimp.html#com_wimptask">
<!ENTITY riscos-command-copy "somescheme:///Command/Copy">
<!ENTITY riscos-vector-wordv "somescheme:///Vectors/WordV">
<!ENTITY riscos-section-vectors "somescheme:///Section/Vectors">
<!ENTITY riscos-section-modules "somescheme:///Section/Modules">
<!ENTITY riscos-section-swis "somescheme:///Section/SWIs">
<!ENTITY riscos-section-oswords "somescheme:///Section/OSWords">
<?xml version="1.0" standalone="yes"?>

<!-- RISC OS PRM stylesheet - written by hand; apologies for errors in
     style -->

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/TR/xhtml1/strict">
                
<xsl:output method="html" indent="no"/>

<xsl:template match="/">
<html><xsl:apply-templates/></html>
</xsl:template>

<xsl:template match="chapter[5">
thingy
</xsl:template>

<xsl:template match="chapter">
<head>
  <title>
    RISC OS Programmers Reference Manuals : 
    <xsl:value-of select="@title"/>
  </title>
</head>

<body bgcolor="white" text="black" link="blue" alink="red" vlink="darkblue">

<hr />
<h1><xsl:value-of select="@title"/></h1>
<hr />

<xsl:apply-templates select="section"/>

</body>

</xsl:template>

<!-- Sections -->
<xsl:template match="section">
<dl>
 <dt><h2><xsl:value-of select="@title" /></h2></dt>
 <dd>
  <dl>
   <dd>
    <xsl:apply-templates/>
   </dd>
  </dl>
 </dd>
</dl>
<hr />
</xsl:template>

<!-- Sub-Sections -->
<xsl:template match="subsection">
<dt><h4><xsl:value-of select="@title" /></h4></dt>
<dd>
 <xsl:apply-templates/>
</dd>
</xsl:template>

<!-- command definitions ? -->
<xsl:template match="command-definition">
<hr />
<h2 align="right">*<xsl:value-of select="@command"/></h2>
<xsl:value-of select="@description"/>

<dt><h5>Syntax</h5></dt>
<dd>
<xsl:choose>
 <xsl:when test="count(syntax)=0">
  *<xsl:value-of select="@command"/>
 </xsl:when>
 <xsl:otherwise>
  <xsl:for-each select="syntax">
   <code>*<xsl:value-of select="//@command"/>
    <xsl:apply-templates />
   </code>
  </xsl:for-each>
 </xsl:otherwise>
</xsl:choose>
</dd>

<dt><h5>Parameters</h5></dt>
<dd>
<xsl:choose>
 <xsl:when test="count(parameter)=0">None</xsl:when>
 <xsl:otherwise>
  <table summary="Command parameters" border="0">
  <xsl:for-each select="parameter">
   <tr><td valign="top"><code><i><xsl:value-of select="@name" /></i></code></td>
       <td valign="top">-</td>
       <td valign="top"><xsl:apply-templates /></td>
   </tr>
  </xsl:for-each>
  </table>
 </xsl:otherwise>
</xsl:choose>
</dd>

<xsl:apply-templates select="use" />

<xsl:choose>
 <xsl:when test="count(example) > 0">
  <!-- I've probably missed an easier way to do this... -->
  <xsl:choose>
   <xsl:when test="count(example) = 1">
    <dt><h5>Example</h5></dt>
   </xsl:when>
   <xsl:otherwise>
    <dt><h5>Examples</h5></dt>
   </xsl:otherwise>
  </xsl:choose>

  <xsl:for-each select="example">
   <dd>
    <xsl:apply-templates />
   </dd>
  </xsl:for-each>
 </xsl:when>
</xsl:choose>

<dt><h5>Related commands</h5></dt>
<dd>
<xsl:choose>
 <xsl:when test="count(related-commands) = 0">None</xsl:when>
 <xsl:otherwise>
  <xsl:for-each select="related-commands">
  <xsl:if test="position() > 1">, </xsl:if>
   <a>
    <xsl:attribute name="href">
     <xsl:value-of select="@href"/>
    </xsl:attribute>
    *<xsl:value-of select="@name"/>
   </a>
  </xsl:for-each>
 </xsl:otherwise>
</xsl:choose>
</dd>

<dt><h5>Related SWIs</h5></dt>
<dd>
<xsl:choose>
 <xsl:when test="count(related-swis) = 0">None</xsl:when>
 <xsl:otherwise>
  <xsl:for-each select="related-swis">
  <xsl:if test="position() > 1">, </xsl:if>
   <a>
    <xsl:attribute name="href">
     <xsl:value-of select="@href"/>
    </xsl:attribute>
    *<xsl:value-of select="@name"/>
   </a>
  </xsl:for-each>
 </xsl:otherwise>
</xsl:choose>
</dd>

<dt><h5>Related vectors</h5></dt>
<dd>
<xsl:choose>
 <xsl:when test="count(related-vectors) = 0">None</xsl:when>
 <xsl:otherwise>
  <xsl:for-each select="related-vectors">
  <xsl:if test="position() > 1">, </xsl:if>
   <a>
    <xsl:attribute name="href">
     <xsl:value-of select="@href"/>
    </xsl:attribute>
    *<xsl:value-of select="@name"/>
   </a>
  </xsl:for-each>
 </xsl:otherwise>
</xsl:choose>
</dd>
 
</xsl:template>

<xsl:template match="use">
<dt><h5>Use</h5></dt>
<dd>
 <xsl:apply-templates />
</dd>
</xsl:template>


<xsl:template match="swi-definition">
<hr />
<h2 align="right"><xsl:value-of select="@name"/><br />
    (<acronym>SWI &amp;<xsl:value-of select="@number"/></acronym>)</h2>
<xsl:choose>
 <xsl:when test="@internal = 'yes'">
 <p>This SWI call is for internal use only. You must not use it in your own
    code.</p></xsl:when>
 <xsl:otherwise>
  <xsl:value-of select="@description"/>
  
  <dt><h5>On entry</h5></dt>
  <dd>
  <xsl:choose>
   <xsl:when test="count(entry/*)=0">None</xsl:when>
   <xsl:otherwise>
    <table summary="Conditions on entry to SWI" border="0">
    <xsl:apply-templates select="entry"/>
    </table>
   </xsl:otherwise>
  </xsl:choose>
  </dd>
  
  <dt><h5>On exit</h5></dt>
  <dd>
  <xsl:choose>
   <xsl:when test="count(exit/*)=0">None</xsl:when>
   <xsl:otherwise>
    <table summary="Conditions on exit from SWI" border="0">
    <xsl:apply-templates select="exit"/>
    </table>
   </xsl:otherwise>
  </xsl:choose>
  </dd>
  
  <dt><h5>Interrupts</h5></dt>
  <dd>Interrupts are <xsl:value-of select="@irqs" /><br />
      Fast interrupts are <xsl:value-of select="@fiqs"/></dd>

  <dt><h5>Processor mode</h5></dt>
  <dd>Processor is in <xsl:value-of select="@processor-mode"/> mode
  </dd>

  <dt><h5>Re-entrancy</h5></dt>
  <dd>
  <xsl:choose>
    <xsl:when test='@re-entrant="yes"'>SWI is re-entrant</xsl:when>
    <xsl:when test='@re-entrant="undefined"'>Not defined</xsl:when>
    <xsl:when test='@re-entrant="no"'>SWI is not re-entrant</xsl:when>
    <xsl:otherwise><xsl:value-of select="@re-entrant"/></xsl:otherwise>
  </xsl:choose>
  </dd>

  <xsl:apply-templates select="use" />

  <xsl:choose>
   <xsl:when test="count(example) > 0">
    <!-- I've probably missed an easier way to do this... -->
    <xsl:choose>
     <xsl:when test="count(example) = 1">
      <dt><h5>Example</h5></dt>
     </xsl:when>
     <xsl:otherwise>
      <dt><h5>Examples</h5></dt>
     </xsl:otherwise>
    </xsl:choose>

    <xsl:for-each select="example">
     <dd>
      <xsl:apply-templates />
     </dd>
    </xsl:for-each>
   </xsl:when>
  </xsl:choose>

  <dt><h5>Related commands</h5></dt>
  <dd>
  <xsl:choose>
   <xsl:when test="count(related-commands) = 0">None</xsl:when>
   <xsl:otherwise>
    <xsl:for-each select="related-commands">
    <xsl:if test="position() > 1">, </xsl:if>
     <a>
      <xsl:attribute name="href">
       <xsl:value-of select="@href"/>
      </xsl:attribute>
      *<xsl:value-of select="@name"/>
     </a>
    </xsl:for-each>
   </xsl:otherwise>
  </xsl:choose>
  </dd>

  <dt><h5>Related SWIs</h5></dt>
  <dd>
  <xsl:choose>
   <xsl:when test="count(related-swis) = 0">None</xsl:when>
   <xsl:otherwise>
    <xsl:for-each select="related-swis">
    <xsl:if test="position() > 1">, </xsl:if>
     <a>
      <xsl:attribute name="href">
       <xsl:value-of select="@href"/>
      </xsl:attribute>
      <xsl:value-of select="@name"/>
     </a>
    </xsl:for-each>
   </xsl:otherwise>
  </xsl:choose>
  </dd>

  <dt><h5>Related vectors</h5></dt>
  <dd>
  <xsl:choose>
   <xsl:when test="count(related-vectors) = 0">None</xsl:when>
   <xsl:otherwise>
    <xsl:for-each select="related-vectors">
    <xsl:if test="position() > 1">, </xsl:if>
     <a>
      <xsl:attribute name="href">
       <xsl:value-of select="@href"/>
      </xsl:attribute>
      <xsl:value-of select="@name"/>
     </a>
    </xsl:for-each>
   </xsl:otherwise>
  </xsl:choose>
  </dd>
  
 </xsl:otherwise>
</xsl:choose>
 
</xsl:template>

<xsl:template match="use">
<dt><h5>Use</h5></dt>
<dd>
 <xsl:apply-templates />
</dd>
</xsl:template>

<!-- Register -->
<xsl:template match="register-use">
<tr>
<xsl:choose>
 <xsl:when test="@state='preserved'">
  <td valign="top" align="left" colspan="3">
  R<xsl:value-of select="@number"/> preserved
  </td>
 </xsl:when>
 <xsl:when test="@state='corrupted'">
  <td valign="top" align="left" colspan="3">
  R<xsl:value-of select="@number"/> corrupted
  </td>
 </xsl:when>
 <xsl:otherwise>
  <td valign="top" align="right">
  R<xsl:value-of select="@number"/>
  </td>
  <td valign="top">=</td>
  <td valign="top" align="left">
   <xsl:apply-templates/>
  </td>
 </xsl:otherwise>
</xsl:choose>
</tr>
</xsl:template>


<!-- A bitfield-table turns into a regular XHTML table, with header -->
<xsl:template match="bitfield-table">
<table summary="A bitfield" border="0">
 <tr>
 <xsl:choose>
  <xsl:when test="count(bit-range)=0">
   <th valign="top">Bit</th><th valign="top">Meaning if set</th>
  </xsl:when>
  <xsl:otherwise>
   <th valign="top">Bit(s)</th><th valign="top">Meaning</th>
  </xsl:otherwise>
 </xsl:choose>
 </tr>
 <xsl:apply-templates/>
</table>
</xsl:template>

<xsl:template match="bit">
<tr>
 <td valign="top" align="right"><xsl:value-of select="@number"/></td>
 <td valign="top" align="left"><xsl:apply-templates/></td>
</tr>
</xsl:template>

<!-- References; we assume entities are used to resolve repositories; is
     this sane ? -->
<xsl:template match="reference">
<a>
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
<xsl:apply-templates /></a>
</xsl:template>

<!-- Paragraphs are simple -->
<xsl:template match="p">
<p><xsl:apply-templates /></p>
</xsl:template>

<!-- User replacement -->
<xsl:template match="userreplace">
<i>&lt;<xsl:apply-templates />&gt;</i>
</xsl:template>

<!-- Command example -->
<xsl:template match="command">
<code><xsl:apply-templates /></code>
</xsl:template>

<!-- User replacement -->
<xsl:template match="optional">
[<xsl:apply-templates />]
</xsl:template>

<!-- Stylistic changes -->
<!-- These should really be removed ASAP and replaced with more content-based
     elements, such as warning, important or note -->
<xsl:template match="strong">
<strong><xsl:apply-templates /></strong>
</xsl:template>
<xsl:template match="em">
<em><xsl:apply-templates /></em>
</xsl:template>

</xsl:stylesheet> 
<?xml version="1.0"?>
<?xml-stylesheet href="riscos-prm.xsl" type="text/xsl"?>
<!DOCTYPE riscos-prm SYSTEM "riscos-prm.dtd">

<chapter title="ComponentTitle">
<section title="Introduction and Overview">
<p>Brief introduction</p>

</section>

<section title="Terminology">
<p>Any terms we need to define.</p>

</section>

<section title="Technical Details">
<p>How it does stuff, and how you talk to it.</p>

</section>

<section title="SWI calls">
<swi-definition name="Prefix_Name"
                number="number"
                description="Overview of functionality"
                irqs="enabled, disabled or a description of state"
                fiqs="enabled, disabled or a description of state"
                processor-mode="SVC, IRQ, FIQ"
                re-entrant="yes, no, undefined">

<entry>
 <register-use number="0">meaning of register 0</register-use>
</entry>
<exit>
 <register-use number="0" state="preserved, corrupted or omitted if a body is supplied for its value" />
</exit>
<use>
<p>Long description of this SWI</p>

</use>

<!-- <related-commands name="Com" href="&riscos-command-com;" /> -->
<!-- <related-swis name="thingy" href="&riscos-swi-thingy;" /> -->
<!-- <related-vectors name="bingleV" href="&riscos-vector-bingle;" /> -->

</swi-definition>
</section>

<section title="*Commands">
<command-definition
 command="CommandName"
 description="Short description of command">
<syntax>
 <userreplace>parameter</userreplace>
 <optional><userreplace>another_one</userreplace></optional>
</syntax>

<parameter name="parameter">
 What it means
</parameter>
<parameter name="another_one">
 What it means, too
</parameter>

<use>
Long description of use.
</use>

<example>
<command>CommandName ToDoStuff WithStuff</command>
</example>

<!-- <related-commands name="Com" href="&riscos-command-com;" /> -->
<!-- <related-swis name="thingy" href="&riscos-swi-thingy;" /> -->
<!-- <related-vectors name="bingleV" href="&riscos-vector-bingle;" /> -->

</command-definition>
</section>

</chapter>
<?xml version="1.0" standalone="yes"?>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/TR/xhtml1/strict">

<xsl:template match="chapter[5">
thingy
</xsl:template>
<?xml version="1.0"?>
<?xml-stylesheet href="example.xsl" type="text/xsl"?>

<thingy>
</thingy>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]