I can't for the love of god figure out what the #Guile #SXML / #SSAX equivalent is to XML's <!-- comment --> tags, or how to properly define my own, since sxml->xml transforms all "< >" characters to "&lt; &rt;".

I'm going to take a break from that now, though.

@MutoShack

didi you try to do the opposite ?

Did you try to parse a fragment of xml containing a comment to see what the resulting sxml is ?

@AbbieNormal

Yeah. Using a comment alone:
(xml->sxml "<!-- text -->")
gives me an "Unexpected EOF" error.

However, using a comment with proper HTML tags:

(xml->sxml
"<!DOCTYPE html>\
<html>\
<body>\
<!-- text -->\
</body> </html>")

Will output the tree:
(*TOP* (html (body)))

It looks like Guile sees the comment, but removes it from the tree.

Some SXML implementations use the token *COMMENT*, so at least I have some code to read. I just don't want to use an external module for something so seemingly simple.

@MutoShack

I scanned the source (git.savannah.gnu.org/cgit/guil) and didn't see any specific token for comments so you'll have to do some major mods to get it in there.

You could probably expand the default element handler but it'll take some work.

@drewfer

Thanks, I didn't get around to that.

It's weird though, cause comments are part of the XML standard (I'm fairly certain)! Then again, I guess Guile's implementation of SXML isn't exactly robust just yet.

Thanks for the help anyway, Drewfer!

Follow

@MutoShack I also checked the w3c standard (yeah...went off the deep end here) and it states "an XML processor MAY, but need not, make it possible for an application to retrieve the text of comments".

I guess they embraced the 'MAY' here :)

@drewfer

Thanks, again.
It's a popular choice. I found quite a few SXML implementations that decide to take the "ignore comments" route, and honestly, I don't blame them. I don't know why the standard isn't something like:
<comment>
text
</comment>
which would mean processors wouldn't have to do *extra* work to deal with them!

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.