Sorry, The description of open is a bit confusing.
open!=0 mains: the tag itself is not such as "<p/>" and there is not a
paired "</p>" exists. This is useful in the following condition:
If someone want to rander the result of SGML back to html, SGMLatom->open
indicate whether he should append a "</tagname>" after he randered
SGMLatom->data.
In your example, if o->result()[0]->open==1 the result array should be
randered as "<p><x/>". This happened in following case:
void main()
{
object o = Parser.SGML.SGML();
mixed v=o->feed ("<haha><p><x/></haha></p>")->finish();
write("%O",v);
}
The result:
({ /* 2 elements */
SGMLatom(<haha/>
SGMLatom(<p> <---- notice: <p> is open,
<p/> is not
SGMLatom(<x/>))),
SGMLatom(</p>)
})
<p> is completed by SGML when meeting a outer end tag "</haha>". Without
"open", we can't know whether the result is from "<haha><p><x/></haha></p>"
or "<haha><p><x/></p></haha></p>" .
--------------------------------------------------
From: "Martin Stjernholm" <<mast[at]lysator.liu.se>>
Sent: Sunday, April 05, 2009 3:31 AM
To: "PeterPan" <<zenothing[at]hotmail.com>>
Cc: <<pike[at]roxen.com>>
Subject: Re: submit modify of Parser.SGML
> "PeterPan" <<zenothing[at]hotmail.com>> wrote:
>
>> * recognize xml-compatible tag such as <p/>, set open=0 for these tags
>
> This doesn't seem to work though:
>
> > object o = Parser.SGML.SGML();
> > o->feed ("<p><x/></p>")->finish();
> (1) Result: ({ /* 1 element */
> SGMLatom(size 1)
> })
> > o->result()[0]->open;
> (2) Result: 0
>
> I.e. it incorrectly flags the <p> tag as not open.
>
>
|