Forum OpenACS Development: Re: Developmnet tools, debuggers, IDEs, etc

Collapse
Posted by Bart Teeuwisse on
Mark,

you've gotten rid of the "external entity not found" warning because of the last line in the catalog:

    DOCTYPE master "xhtml1-transitional.dtd"

This tells PSGML to treat all files opened in PSGML mode starting with <master> to be treated as XHTML.

While this gets rid of the aforementioned error, it does have a side effect which might be worse. I found that indenting a region (M-x indent-region or C-M-\) doesn't work well anymore. In particular when the region contains <if> ADP tags.

Should find indenting to be more important than the present of an warning message when you open an ADP file then I recommend removing the last line in the catalog.

On the other hand, the added benefit of the catalog line is that you can now use C-c C-e (and other PSGML key bindings) to insert valid XHTML tags. Of course this doesn't help with ADP tags as the XHTML dtd doesn't know about those.

Please note that you would still get the "extrenal entity not found" warning for ADP files NOT starting with <master>.

In short, there is no perfect solution, which is not suprising as ADP files are not valid XML. But depending on your preferences you can configure a workable environment.

/Bart

Collapse
Posted by Talli Somekh on
How hard would it be to get the AOLserver community to begin considering making ADP valid XML? is it an impossibility? what would be the advantages?

talli

Collapse
Posted by Bart Teeuwisse on
Talli,

ADPs can't always be valid XML. See https://openacs.org/forums/message-view?message_id=158094.

/Bart

Collapse
Posted by Tom Jackson on

Talli, also check this thread on XML like syntax for a templating system. IMHO, actually making ADPs and ATS conform to XML would be unhelpful. XSL achieves it by interpreting its XML tags and rewriting the surrounding XML/text. But it isn't very readable, and this type of process is probably impossible for ADP and ATS processing.

In the above thread I discuss the possibility of a separate templating system with improved properties in certain areas. One area is validation of the template.

Without going to the extreme of XSL, I doubt you can construct an valid XML document that is also a template. The main problem is attribute values, whose value validation probably wouldn't match up in many cases with the variable format. But a template doesn't have to be valid XML to be a valid template, obviously. What would be nice is if the templating system could validate the template while transforming it into code. This is the approach I have taken.

The ATS compiler could be rewritten to do this as well. Essentially you would throw out the adp tag processor and replace it with a top down scanner/parser. The recursive nature of the ATS compiler makes it difficult to understand and extend. Since my new toy is top down, it is very easy to extend. For instance, this weekend I added the following 'tag':

[resource type name args]

# which is converted by the scanner/parser to:
if {[::resource::exists $type $name]} {
   ::resource::eval $type $name $args
}

# ::resource::eval in turn, just runs:
::resource::$type $name $args

So to answer your question, Talli: it may not be impossible, but I don't see any advantages given what the result would look like. And it doesn't appear that the toolkit has room for another templating system, regardless of the properties.

Collapse
Posted by Andrei Popov on

Tom,

I can't see why this:

<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <title>@title@</title> <!-- keep @var@'s -->
</head>

<body>
  <p>Got a list @list@</p>
  <p>Looping over list:</p>
  <ul>
    <tcl:foreach name="l" select="list">
      <li><tcl:value-of select="l" /></li>
    </tcl:foreach>
  </ul>

  <p>Got an array @array@</p>

  <p>Looping over Array:</p>
  <table>
    <tr>
      <th>Name</th>
      <th>Age</th>

      <th>City</th>
    </tr>
    <tcl:foreach name="a" select="array">
      <tr>
        <td><tcl:value-of select="a(name)" /></td>
        <td><tcl:value-of select="a(age)" /></td>
        <td><tcl:value-of select="a(city)" /></td>
      </tr>
    </tcl:foreach>
  </table>

</body>
</html>

would look much worse than this:

<html>
<head>
 <title>$title</title>
</head>
<body>

<p>Got a list $list

<p>Looping over list:
<ul>
[foreach l $list]
 <li>$l</li>
[/foreach]
</ul>

<p>Got an array $array
<p>Looping over Array:

<table>
<tr>
 <th>Name</th>
 <th>Age</th>
 <th>City</th>

</tr>
[foreach a $array]
<tr>
 <td>$a(name)</td>
 <td>$a(age)</td>
 <td>$a(city)</td>

</tr>
[/foreach]
</table>

</body>
</html>

Naturally, it *is* different, but as stated in the same thread mentioned by you --- there is no need/point in really implementing XSL. Borrowing *some* structures/approachs is all that can make ADPs valid, and hence much easier handled by a variety of tools. For one, you could actually apply a style sheet to them and display them in a browser and/or create printable output, etc.

The <tcl:value-of-select> could be replaced by the current @@ syntax for easier readability, if so required. Or shortened to <tcl:value-of>.

Collapse
Posted by Tom Jackson on

Andrei, I wasn't going for look. I started the other thead with a set of criteria for my templating grammar. I initially thought there might be some benefit to an XML-like look, but alas, it isn't XML, and my purpose was beyond producing XML-like documents.

I believe the main problem with the XSL approach is that in order to place values inside other XML tags, you have to construct the tag, piece by piece. To me this is too verbose and unreadable.

As far as development tools, debuggers, etc. I shouldn't have much problem with my grammer, since I know it is a valid grammar. Debugging is easy: compiling checks the grammar, then you can read the simple tcl script which results to see if there are problems there. Getting Dreamweaver to recoginze the tags will also be easy. I could have separate icons for each language element, so that in design view, you could still tell what language tags were being used. Fortunately the template compiler is essentially complete. The resource tag was the last main requirement, allowing the developer to tailor exactly what is available to the designer. I'm still considering whether to add while and switch/case tags, but the for tag is too dangerous since it executes the first arg.