Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-30 Thread Matt Gushee
Hi, Jim--

Thanks for all your work on this!

On Sun, Aug 25, 2013 at 1:57 AM, Jim Ursetto zbignie...@gmail.com wrote:
 On Aug 24, 2013, at 5:25 PM, Jim Ursetto zbignie...@gmail.com wrote:

 Unfortunately it doesn't declare the default namespace for html.  You can 
 work around this by providing a default namespace prefix *and* using the 
 actual prefix (below, xhtml:) on your elements.  This is kind of ugly.  
 However, the stock serializer didn't even support default namespaces (!) so 
 I may have simply overlooked this case when adding support.  I'll see if I 
 can look into it further.

 I've added support for the default (unqualified) namespace ID in the source 
 SXML now; the code is available at https://github.com/ursetto/sxml-serializer 
 while I run a couple more tests.  Formerly, you could render to unqualified 
 names but not use them properly in the source.

I'm not sure what you mean by use them properly in the source.
Actually, other than the problem with lowdown, I was getting just the
results I wanted before. Specifically, I'm working with my civet
templating system, which I created a few months ago, and up to version
0.3 of sxml-serializer, I got output with a default namespace
declaration and unqualified element names ... the default namespace
was represented in my SXML as '(#f ns-uri) ... with sxml-serializer
0.4, they are getting an arbitrary prefix applied to them. So that's a
step backwards for me.

 [Note: below, unqualified names are rendering to the xhtml: namespace, 
 because there is a list of default namespace URI - ID mappings, called 
 conventional-ns-prefixes.  To override this and render them without 
 qualification, add *default* as the 3rd arg of the namespace association (as 
 the original prefix).

I'm not following that. Where is there a 3rd argument?

 The word original is used as if the XML document was the original source 
 and you had parsed it to SXML;

... which is in fact the case.

 the SXML prefix and XML prefix are permitted to differ.]

I know, and it seems like an unnecessary complication to me ... but I
suppose it must be a useful feature for some users.

--
Matt Gushee

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-30 Thread Matt Gushee
Oh, wait ...

On Fri, Aug 30, 2013 at 1:44 AM, Matt Gushee m...@gushee.net wrote:

 results I wanted before. Specifically, I'm working with my civet
 templating system, which I created a few months ago, and up to version
 0.3 of sxml-serializer, I got output with a default namespace
 declaration and unqualified element names ... the default namespace
 was represented in my SXML as '(#f ns-uri) ... with sxml-serializer
 0.4, they are getting an arbitrary prefix applied to them. So that's a
 step backwards for me.

Oops. Disregard that. I need to read my own stuff better. What
actually happened is that I just bumped the version number on the
NSURI for the template vocabulary, but I forgot to update it in the
templates I'm working with, so the template processor didn't recognize
them. And just an hour ago I was reminding myself of the need to
document that very thing!

However, I see I'm not getting the default namespace declaration. I
thought it was there before, but I'm not sure, and I seem to have
deleted all the older output files.

--
Matt Gushee

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-25 Thread Jim Ursetto
On Aug 24, 2013, at 5:25 PM, Jim Ursetto zbignie...@gmail.com wrote:

 Unfortunately it doesn't declare the default namespace for html.  You can 
 work around this by providing a default namespace prefix *and* using the 
 actual prefix (below, xhtml:) on your elements.  This is kind of ugly.  
 However, the stock serializer didn't even support default namespaces (!) so I 
 may have simply overlooked this case when adding support.  I'll see if I can 
 look into it further.

I've added support for the default (unqualified) namespace ID in the source 
SXML now; the code is available at https://github.com/ursetto/sxml-serializer 
while I run a couple more tests.  Formerly, you could render to unqualified 
names but not use them properly in the source.

[Note: below, unqualified names are rendering to the xhtml: namespace, because 
there is a list of default namespace URI - ID mappings, called 
conventional-ns-prefixes.  To override this and render them without 
qualification, add *default* as the 3rd arg of the namespace association (as 
the original prefix).  The word original is used as if the XML document was 
the original source and you had parsed it to SXML; the SXML prefix and XML 
prefix are permitted to differ.]


(use sxml-serializer)

(print
 (serialize-sxml
 '(*TOP*
   (@ (*NAMESPACES*
   (*default* http://www.w3.org/1999/xhtml;)
   (cvt http://xmlns.therebetygers.net/civet/0.1;)))
   (*PI* xml version=\1.0\ encoding=\utf-8\)
(html
 (@ (xml:lang en) (lang en))
 (cvt:template
  (cvt:head
   (cvt:locale (@ (lang en) (country US) (encoding utf-8
(cvt:block (@ (name headerContent))
 #\ Single #\space (#\a #\r #\t #\i #\c #\l #\e)
 #\space page
  ))

?xml version=1.0 encoding=utf-8?
xhtml:html xmlns:xhtml=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
  cvt:template xmlns:cvt=http://xmlns.therebetygers.net/civet/0.1;
cvt:head
  cvt:locale lang=en country=US encoding=utf-8 /
/cvt:head
cvt:block name=headerContentlt;Single article pagegt;/cvt:block
  /cvt:template
/xhtml:html


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-24 Thread Jim Ursetto
Matt,

On Aug 22, 2013, at 3:28 PM, Matt Gushee m...@gushee.net wrote:

 Sounds good. I was actually hoping to be able to blame lowdown for
 this, since I don't really like the way it makes every word and every
 space a separate text node. But maybe that's more efficient? And
 actually, I'm wondering if that character-in-list construction:
 
  '(#\space)
 
 is really allowed by the SXML spec. The narrative documentation
 doesn't address that, and I'm a bit out of practice reading EBNF, but
 maybe I can puzzle it out.

I've modified sxml-serializer in 0.3 to accept chars, symbols and nulls as text 
nodes, and to accept text nodes in list head position.  This should allow it to 
parse lowdown's variant of SXML.

 I note that lowdown
 outputs the '' and '' in string form, whereas the '' becomes #\.
 That seems like a peculiar inconsistency, but I suppose there's some
 reason for it.

Probably lowdown is using (abusing?) the fact that the 
universal-conversion-rules only escape string text nodes, whereas characters 
etc. are output verbatim; it's generally not necessary to escape the  sign.

Jim
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-24 Thread Jim Ursetto
On Aug 23, 2013, at 11:24 PM, Matt Gushee m...@gushee.net wrote:

 Hello again--
 
 Well, I'm running into a new problem with SRV:send-reply. By following
 the documentation, I managed to create a rule set that escaped problem
 characters i the manner I want. But now, working with the complete
 document, I discover that some of the non-element nodes are not
 handled properly. The SXML form of my document starts like this:
 
  (*TOP*
(@ (*NAMESPACES*
  (#f http://www.w3.org/1999/xhtml;)
  (cvt http://xmlns.therebetygers.net/civet/0.1;)))
(*PI* xml version=\1.0\ encoding=\utf-8\)
(html
  (@ (xml:lang en) (lang en))
 
 But when I serialize it with (SRV:send-reply (pre-post-order tree
 rules)), the output begins like this:
 
  *TOP*
  *NAMESPACES*=http://www.w3.org/1999/xhtml
   cvt=http://xmlns.therebetygers.net/civet/0.1;
  *PI*xmlversion=quot;1.0quot; encoding=quot;utf-8quot;/*PI*
  html xml:lang=en lang=en

This should serialize reasonably correctly with sxml-serializer.

(use sxml-serializer)

(print
 (serialize-sxml
 '(*TOP*
   (@ (*NAMESPACES*
   (#f http://www.w3.org/1999/xhtml;)
   (cvt http://xmlns.therebetygers.net/civet/0.1;)))
   (*PI* xml version=\1.0\ encoding=\utf-8\)
(html
 (@ (xml:lang en) (lang en))
 (cvt:template
  (cvt:head
   (cvt:locale (@ (lang en) (country US) (encoding utf-8
   (cvt:block (@ (name headerContent))
 #\ Single #\space (#\a #\r #\t #\i #\c #\l #\e) #\space page))

?xml version=1.0 encoding=utf-8?
html xml:lang=en lang=en
  cvt:template xmlns:cvt=http://xmlns.therebetygers.net/civet/0.1;
cvt:head
  cvt:locale lang=en country=US encoding=utf-8 /
/cvt:head
cvt:block name=headerContentlt;Single article pagegt;/cvt:block
  /cvt:template
/html

Unfortunately it doesn't declare the default namespace for html.  You can work 
around this by providing a default namespace prefix *and* using the actual 
prefix (below, xhtml:) on your elements.  This is kind of ugly.  However, the 
stock serializer didn't even support default namespaces (!) so I may have 
simply overlooked this case when adding support.  I'll see if I can look into 
it further.

(print
 (serialize-sxml
 '(*TOP*
   (@ (*NAMESPACES*
   (xh http://www.w3.org/1999/xhtml;)
   (cvt http://xmlns.therebetygers.net/civet/0.1;)))
   (*PI* xml version=\1.0\ encoding=\utf-8\)
(xh:html
 (@ (xml:lang en) (lang en))
 (cvt:template
  (cvt:head
   (cvt:locale (@ (lang en) (country US) (encoding utf-8
(cvt:block (@ (name headerContent))
 #\ Single #\space (#\a #\r #\t #\i #\c #\l #\e)
 #\space page
 ns-prefixes: '((*default* . http://www.w3.org/1999/xhtml;))
  ))

?xml version=1.0 encoding=utf-8?
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
  cvt:template xmlns:cvt=http://xmlns.therebetygers.net/civet/0.1;
cvt:head
  cvt:locale lang=en country=US encoding=utf-8 /
/cvt:head
cvt:block name=headerContentlt;Single article pagegt;/cvt:block
  /cvt:template
/html


Namespaces can be tricky.  Check my blog posts on the subject and feel free to
ask for help.

http://3e8.org/blog/2010/07/30/namespaces-in-sxml-part-1/
http://3e8.org/blog/2010/07/31/namespaces-in-sxml-part-2/
http://3e8.org/blog/2010/08/01/default-namespaces-in-sxml/

Jim
___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-23 Thread Matt Gushee
Hello again--

Well, I'm running into a new problem with SRV:send-reply. By following
the documentation, I managed to create a rule set that escaped problem
characters i the manner I want. But now, working with the complete
document, I discover that some of the non-element nodes are not
handled properly. The SXML form of my document starts like this:

  (*TOP*
(@ (*NAMESPACES*
  (#f http://www.w3.org/1999/xhtml;)
  (cvt http://xmlns.therebetygers.net/civet/0.1;)))
(*PI* xml version=\1.0\ encoding=\utf-8\)
(html
  (@ (xml:lang en) (lang en))

But when I serialize it with (SRV:send-reply (pre-post-order tree
rules)), the output begins like this:

  *TOP*
  *NAMESPACES*=http://www.w3.org/1999/xhtml
   cvt=http://xmlns.therebetygers.net/civet/0.1;
  *PI*xmlversion=quot;1.0quot; encoding=quot;utf-8quot;/*PI*
  html xml:lang=en lang=en

... which is obviously not quite right. I suppose it should be
possible to create conversion rules for the *TOP*, *NAMESPACES*, and
*PI* nodes, but I don't understand the syntax well enough. Are there
any examples out there of how to do this?

--
Matt Gushee

On Thu, Aug 22, 2013 at 3:01 PM, Moritz Heidkamp
mor...@twoticketsplease.de wrote:
 Hi Matt,

 Matt Gushee m...@gushee.net writes:
 markdown-sxml converts whitespace in the input to character objects,
 or lists of character objects, e.g.:

'(#\space)
#\newline

 ... but serialize-sxml can't handle these: evidently it wants either
 strings or symbols. I haven't found any arguments or parameters in
 either egg that seem to be able to affect this behavior.

 yeah, Lowdown is cheating a bit here. Those individual characters fall
 right out of the parser and it would require an additional walk of the
 result to turn them into strings. As you already found out, this is not
 really part of the SXML spec but most tools allow characters just fine
 (sxml-serializer is an exception here and is particularly strict). Same
 applies to the additional list wrapping. I usually serialize SXML like
 this:

   (use sxml-transforms)
   (define some-data '(some #\d (#\a ta)))
   (SRV:send-reply (pre-post-order some-data) universal-conversion-rules))

 Which outputs:

   somedata/some

 As you can see, universal-conversion-rules and SRV:send-reply (what's
 the deal with that name?) don't care much about the structure. Note that
 characters will not be entity escaped though, they are just passed
 through as-is.

 However, I do take your point and I think if I advertise Lowdown as
 producing SXML I should better change it to produce SXML according to
 spec :-) I hope I will get around to changing this soon but can't
 promise when. I also hope the workaround above will serve you until
 then!

 Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-22 Thread Matt Gushee
Hi, Jim--

On Wed, Aug 21, 2013 at 10:12 PM, Jim Ursetto zbignie...@gmail.com wrote:
 I don't remember offhand what the rationale was for this in sxml-serializer 
 -- I can take a look but it might not be until this weekend.

Sounds good. I was actually hoping to be able to blame lowdown for
this, since I don't really like the way it makes every word and every
space a separate text node. But maybe that's more efficient? And
actually, I'm wondering if that character-in-list construction:

  '(#\space)

is really allowed by the SXML spec. The narrative documentation
doesn't address that, and I'm a bit out of practice reading EBNF, but
maybe I can puzzle it out.

Anyway, thanks. Guess I'll just work around it for now.

--
Matt Gushee

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-22 Thread Moritz Heidkamp
Hi Matt,

Matt Gushee m...@gushee.net writes:
 markdown-sxml converts whitespace in the input to character objects,
 or lists of character objects, e.g.:

'(#\space)
#\newline

 ... but serialize-sxml can't handle these: evidently it wants either
 strings or symbols. I haven't found any arguments or parameters in
 either egg that seem to be able to affect this behavior.

yeah, Lowdown is cheating a bit here. Those individual characters fall
right out of the parser and it would require an additional walk of the
result to turn them into strings. As you already found out, this is not
really part of the SXML spec but most tools allow characters just fine
(sxml-serializer is an exception here and is particularly strict). Same
applies to the additional list wrapping. I usually serialize SXML like
this:

  (use sxml-transforms)
  (define some-data '(some #\d (#\a ta)))
  (SRV:send-reply (pre-post-order some-data) universal-conversion-rules))

Which outputs:

  somedata/some

As you can see, universal-conversion-rules and SRV:send-reply (what's
the deal with that name?) don't care much about the structure. Note that
characters will not be entity escaped though, they are just passed
through as-is.

However, I do take your point and I think if I advertise Lowdown as
producing SXML I should better change it to produce SXML according to
spec :-) I hope I will get around to changing this soon but can't
promise when. I also hope the workaround above will serve you until
then!

Moritz

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-22 Thread Matt Gushee
Hi, Moritz--

On Thu, Aug 22, 2013 at 3:01 PM, Moritz Heidkamp
mor...@twoticketsplease.de wrote:

   (use sxml-transforms)
   (define some-data '(some #\d (#\a ta)))
   (SRV:send-reply (pre-post-order some-data) universal-conversion-rules))

Thanks for the suggestion. I'm now working on this.

 the deal with that name?) don't care much about the structure. Note that
 characters will not be entity escaped though, they are just passed
 through as-is.

That could be a problem, since I am outputting web pages ... I just
did an experiment where I inserted '', '', '' . I note that lowdown
outputs the '' and '' in string form, whereas the '' becomes #\.
That seems like a peculiar inconsistency, but I suppose there's some
reason for it. Anyway, am I right in thinking that I can get escaped
characters by using something other than universal-conversion-rules?

--
Matt Gushee

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Lowdown sxml-serializer not working together

2013-08-21 Thread Jim Ursetto
I don't remember offhand what the rationale was for this in sxml-serializer -- 
I can take a look but it might not be until this weekend.

On Aug 21, 2013, at 22:38, Matt Gushee m...@gushee.net wrote:

 Hi, chickeneers--
 
 I am working on an application that uses the lowdown egg to process
 *some* of the input, and sxml-serializer to render the output. I'm
 running into an issue ... I'm not sure if it's really a bug, but it's
 at least an compatibility problem:
 
 markdown-sxml converts whitespace in the input to character objects,
 or lists of character objects, e.g.:
 
   '(#\space)
   #\newline
 
 ... but serialize-sxml can't handle these: evidently it wants either
 strings or symbols. I haven't found any arguments or parameters in
 either egg that seem to be able to affect this behavior.
 
 So, is there something that needs to be fixed in one of these eggs, or
 do I just need to convert the markdown-sxml output to something that
 serialize-sxml can handle? Please advise.
 
 --
 Matt Gushee
 
 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users