OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: SAX2 Lexical Handler Suggestions

[ Lists Home | Date Index | Thread Index ]
  • From: Chris Pratt <chris@planetpratt.com>
  • To: David Megginson <david@megginson.com>,XML Development Interest Group <xml-dev@lists.xml.org>
  • Date: Wed, 12 Jul 2000 13:07:25 -0700

No, let me see if an example will make this clearer, sorry about the Rich Text Format and the length of the message.  I have this XHTML:
 
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd" [
  <!ENTITY % aml SYSTEM "DTD/aml.dtd">
    %aml;
]>
<html xmlns="
http://www.w3.org/1999/xhtml" xmlns:aml="DTD/aml.dtd" xml:lang="en" lang="en">
  <head>
    <title>Andalay Application Server</title>
  </head>
  <body background="/images/binder.jpg" bgcolor="white">
    <table border="0" height="100%" width="100%">
      <tr valign="top">
          <!-- Binding -->
        <td width="75" height="100%"><img src="/xml/images/blank.gif" width="75"/></td>
          <!-- Data -->
        <td width="100%">
          <form action="getpricequote.html" method="post">
            Product: <input type="text" name="product" value="&echo.product;" size="50" maxlength="256"/>
          </form>
          <aml:test name="pricequotelist" isnull="false">
            <hr/>
            <table border="1" bgcolor="#c0c0c0">
              <tr bgcolor="pink">
                <th>Product Name</th>
                <th>Product Description</th>
                <th>Merchant</th>
                <th>Price</th>
                <th>Available</th>
              </tr>
              <aml:list name="pricequotelist" value="pricequote">
                <tr>
                  <td>&pricequote.product;</td>
                  <td>&pricequote.description;</td>
                  <td><a href="&pricequote.url;">&pricequote.merchant;</a></td>
                  <td>&pricequote.amount;</td>
                  <td>&pricequote.available;</td>
                </tr>
              </aml:list>
            </table>
          <aml:else/>
            <aml:test name="pricequote" isnull="false">
              <hr/>
              <table border="1" bgcolor="#c0c0c0">
                <tr bgcolor="pink">
                  <th>Product Name</th>
                  <th>Product Description</th>
                  <th>Merchant</th>
                  <th>Price</th>
                  <th>Available</th>
                </tr>
                <tr>
                  <td>&pricequote.product;</td>
                  <td>&pricequote.description;</td>
                  <td><a href="&pricequote.url;">&pricequote.merchant;</a></td>
                  <td>&pricequote.amount;</td>
                  <td>&pricequote.available;</td>
                </tr>
              </table>
            </aml:test>
          </aml:test>
        </td>
      </tr>
    </table>
  </body>
</html>
 
Which, depending on the current user's context, may end up looking like the following HTML:
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>Andalay Application Server</title>
  </head>
  <body background="/images/binder.jpg" bgcolor="white">
    <table border="0" height="100%" width="100%">
      <tr valign="top">
          <!-- Binding -->
        <td width="75" height="100%"><img src="/xml/images/blank.gif" width="75"></td>
          <!-- Data -->
        <td width="100%">
          <form action="getpricequote.html" method="post">
            Product: <input type="text" name="product" value="Palm V" size="50" maxlength="256">
          </form>
          <hr>
          <table border="1" bgcolor="#c0c0c0">
            <tr bgcolor="pink">
              <th>Product Name</th>
              <th>Product Description</th>
              <th>Merchant</th>
              <th>Price</th>
              <th>Available</th>
            </tr>
            <tr>
              <td>3Com Palm V</td>
              <td>The Palm V is the Sleekest, Coolest PDA Available.</td>
              <td><a href="http://www.buy.com/computers/whatever/palm+v.html">Buy.com</a></td>
              <td>$329.00</td>
              <td>15</td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </body>
</html>
 
The XHTML/AML was initially processed into a directed graph that would resemble this:
 
    StaticPageNode
    EchoEntityNode (&echo.product;)
    StaticPageNode
+---TestPageNode (pricequotelist)
|   StaticPageNode
| +-ListPageNode (pricequotelist)
| | StaticPageNode
| | PriceQuoteEntityNode (&pricequote.product;)
f ^ StaticPageNode
a | PriceQuoteEntityNode (&pricequote.description;)
l | StaticPageNode
s ^ PriceQuoteEntityNode (&pricequote.url;)
e | StaticPageNode
| | PriceQuoteEntityNode (&pricequote.merchant;)
v ^ StaticPageNode
| | PriceQuoteEntityNode (&pricequote.amount;)
| | StaticPageNode
| ^ PriceQuoteEntityNode (&pricequote.availability;)
v | StaticPageNode
| +-LoopPageNode
+---ElsePageNode
| +-TestPageNode (pricequote)
| | StaticPageNode
| | PriceQuoteEntityNode (&pricequote.product;)
| | StaticPageNode
t f PriceQuoteEntityNode (&pricequote.description;)
r a StaticPageNode
u l PriceQuoteEntityNode (&pricequote.url;)
e s StaticPageNode
| e PriceQuoteEntityNode (&pricequote.merchant;)
v | StaticPageNode
| | PriceQuoteEntityNode (&pricequote.amount;)
| v StaticPageNode
v | PriceQuoteEntityNode (&pricequote.availability;)
| | StaticPageNode
| +-NoopPageNode
+---NoopPageNode
    StaticPageNode
 
So when each page request comes in the directed graph is executed to generate the output.  The line:
 
  <td><a href="&pricequote.url;">&pricequote.merchant;</a></td>
 
shows the problem most clearly.  In SAX, the data from the &pricequote.url; entity reference is reported as an entry in the Attributes Object passed to the startElement() call, where as the &pricequote.merchant; is reported in the character() call.  I need to know how this entity was found in the document to know what should preceed and follow it in the directed graph.  I also need to know which of the Attributes actually started life as an Entity Reference so that the proper EntityNode can be added to the graph instead of the replacement text that the parser found in the DTD.  If this isn't clear enough, please let me know.
    (*Chris*)
 
----- Original Message -----
From: "David Megginson" <david@megginson.com>
To: "Chris Pratt" <chris@planetpratt.com>
Sent: Wednesday, July 12, 2000 12:32 PM
Subject: Re: SAX2 Lexical Handler Suggestions

> Chris Pratt wrote:
>  
> > How does XSL deal with these problems?  There's no control over entity
> > references in XSL?  I am basically doing what XSL enables except that I'm
> > caching it in between.  I don't understand how XSL is able to do this using
> > a SAX parser if the rest of us mortals aren't?
>
> XSL doesn't expose internal entity boundaries, but it does expose
> elements and processing instructions.
>
> There's been a lot of terminological confusion in this discussion -- it
> started dealing with entities, but then you (Chris) wrote at length
> about attributes.  I assumed that that was just a slip for 'entities',
> but I may have been wrong.
>
>
> All the best,
>
>
> David
>
> --
> David Megginson                 david@megginson.com
>            http://www.megginson.com/
>



 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS