[m-rev.] For review: use XML browser to browse terms in mdb
Ian MacLarty
maclarty at cs.mu.OZ.AU
Thu Dec 9 16:53:05 AEDT 2004
Please ignore the second reply - I pushed a key by mistake...
Ian.
On 9 Dec 2004, at 16:50, Ian MacLarty wrote:
>
> On 9 Dec 2004, at 14:32, Zoltan Somogyi wrote:
>
>> On 09-Dec-2004, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
>>> XML is dumped and the command used to browse the XML. The defaults
>>> assume
>>> xsltproc and mozilla are installed.
>>
>> How easy would it be to not require xsltproc? For example, my laptop
>> doesn't
>> have it installed. This is a question, not an objection.
>>
> An <?xml-stylesheet ... ?> tag could be included in the XML with a
> reference to the XSL stylesheet. Then in theory the browser should
> apply the stylesheet before displaying the XML, however in practice
> browser support for this seems to be a bit flaky. Mozilla seems to
> have limited support for XSL stylesheets: for example when I included
> a reference to the mercury_term.xsl stylesheet then the stylesheet was
> applied and the Mercury term was displayed as text, however when I
> included a reference to the xul_tree.xsl stylesheet nothing was
> displayed, even when I specify a media-type of
> "application/vnd.mozilla.xul+xml". So that's why I explicitly apply
> the stylesheet using xsltproc before calling mozilla.
>
> Another option is to include a binding to an XML library that supports
> XSL stylesheets (this could be added to Peter's expat binding for
> example), then the stylesheet could be applied in Mercury code before
> being passed to mozilla. However this would rely on you having the
> expat libraries installed.
>
>>> +save_term_to_file_xml(FileName, BrowserTerm, OutStream, !IO) :-
>>> + io__tell(FileName, FileStreamRes, !IO),
>>> + (
>>> + FileStreamRes = ok,
>>> + (
>>> + BrowserTerm = plain_term(Univ),
>>> + Term = univ_value(Univ),
>>> + term_to_xml.write_xml_doc_cc(Term, simple,
>>> + no_stylesheet, no_dtd, _, !IO)
>>> + ;
>>> + BrowserTerm = synthetic_term(Functor, Args, MaybeRes),
>>> + (
>>> + MaybeRes = no,
>>> + PredicateTerm = predicate(Functor, Args),
>>> + term_to_xml.write_xml_doc_cc(PredicateTerm,
>>> + simple, no_stylesheet, no_dtd, _, !IO)
>>> + ;
>>> + MaybeRes = yes(Result),
>>> + FunctionTerm = function(Functor, Args, Result),
>>> + term_to_xml.write_xml_doc_cc(FunctionTerm,
>>> + simple, no_stylesheet, no_dtd, _, !IO)
>>> )
>>> ),
>>
>> The format of the synthetic terms is not the best possible, but it is
>> OK
>> for now. However, you should put an XXX there as a reminder.
>>
> I agree, though I think it's more a change to the stylesheet to get it
> to display predicate/2 and function/3 elements as atoms and to strip
> the univ_cons from the arguments.
>
>>> --- tests/debugger/browser_test.inp 5 Nov 2004 06:30:20 -0000 1.11
>>> +++ tests/debugger/browser_test.inp 9 Dec 2004 01:38:16 -0000
>>> @@ -36,6 +36,10 @@
>>> cdr 3 ../1/..
>>> ls
>>> quit
>>> +set xml_tmp_filename './tmp.xml'
>>> +set xml_browser_cmd 'cat ./tmp.xml'
>>> +browse --xml 1
>>> +browse -x Data
>>> set -A -f depth 1
>>
>> You should add tmp.xml to the list of filenames to be removed by
>> mmake clean
>> in that directory.
>>
> I've instead changed the temporary filename to browser_test.xml.out.
>
>>> +static char MR_xml_browser_command[MR_XML_BROWSER_COMMAND_LENGTH] =
>>> "";
>>> +static char MR_xml_tmp_filename[MR_XML_TMP_FILENAME_LENGTH] = "";
>>
>> The command name definitely should have dynamic size; as big as
>> needed.
>> This would also be nice for the filename.
>>
> I've made them both dynamically sized:
>
>
>>> +static void
>>> +MR_trace_browse_xml(MR_Word type_info, MR_Word value,
>>> + MR_Browse_Caller_Type caller, MR_Browse_Format format)
>>> +{
>>> + MR_Word browser_term;
>>> +
>>> + browser_term = MR_type_value_to_browser_term((MR_TypeInfo)
>>> type_info,
>>> + value);
>>> +
>>> + MR_trace_save_term_xml("tmp.xml", browser_term);
>>> +
>>> + MR_trace_save_and_invoke_xml_browser(browser_term);
>>> +}
>>
>> Why the fixed filename here?
>>
>
> That's a mistake. The call to MR_trace_save_term_xml shouldn't be
> here because MR_trace_save_and_invoke_xml_browser also calls it.
>
>>> - if (! MR_trace_options_param_set(&print_set, &browse_set,
>>> + if (word_count == 3 && MR_streq(words[1], "xml_browser_cmd")) {
>>> + strcpy(MR_xml_browser_command, words[2]);
>>> + } else if (word_count == 3 && MR_streq(words[1],
>>> "xml_tmp_filename")) {
>>> + strcpy(MR_xml_tmp_filename, words[2]);
>>> + } else if (! MR_trace_options_param_set(&print_set, &browse_set,
>>
>> At the very least, check the length of words[2] before doing the
>> assignment.
>>
>
> See above changes.
>
>> Otherwise, the diff is fine. Commit when you have fixed the above.
>>
> I'll only be able to commit it once my changes to term_to_xml have
> been reviewed since these changes depend on that diff.
>
> Cheers,
> Ian.
>
> -----------------------------------------------------------------------
> ---
> mercury-reviews mailing list
> post: mercury-reviews at cs.mu.oz.au
> administrative address: owner-mercury-reviews at cs.mu.oz.au
> unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message:
> unsubscribe
> subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message:
> subscribe
> -----------------------------------------------------------------------
> ---
>
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list