unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Re: can't use variable in sxml-match?
@ 2011-05-20  3:55 Ian Price
  2011-05-20  5:17 ` nalaginrut
  2011-05-31 22:01 ` Ludovic Courtès
  0 siblings, 2 replies; 6+ messages in thread
From: Ian Price @ 2011-05-20  3:55 UTC (permalink / raw)
  To: nalaginrut; +Cc: guile-devel


Hi guilers,

Just a note to say that we found a solution to nalaginrut's problem on IRC.

(lambda (mypattern)
  ;; Instead of testing the head of the pattern in the sxml-match, I
  ;; have moved it out to here.
  (let* ((new-tag (if (equal? mypattern (car cl))
                      'success
                      'fail))
         ;; replace the head with 'success or 'fail depending on a match
         (new-expr (cons new-tag (cdr cl))))
    (sxml-match new-expr
                ;; here we test against the new head
                [(success (@ (type ,tv)) ,cv) ...]
                [,otherwise #f])))

Another suggestion was to use syntax-rules to create the match pattern
at expand time. If anyone else has a better solution, feel free to pipe
up. :)

Ian



^ permalink raw reply	[flat|nested] 6+ messages in thread
* can't use variable in sxml-match?
@ 2011-05-20  1:06 nalaginrut
  2011-05-20  2:26 ` nalaginrut
  0 siblings, 1 reply; 6+ messages in thread
From: nalaginrut @ 2011-05-20  1:06 UTC (permalink / raw)
  To: guile-devel

hi guys!
I got a problem when I using sxml-match.
Let me describe it more briefly:
================Begin=================
    (sxml-match
     cl
     [(http://www.w3.org/2005/Atom:content
       (@ (type ,tv)) ,cv)
	...do something...
     [,otherwise #f])
===============End==================
As you see, I must write "content" with the namespace for some reason.
But I want a more generic solution ,or I must change source code when
namespace changes. Like:
===============Begin===============
(lambda (mypattern)
(sxml-match
  cl
   [(,my-pattern  
      (@ (type ,tv)) ,cv)
     ...............
===============End===============

I can't substitute 'http://www.w3.org/2005/Atom:content by a variable,
say ,mypattern. It spews a lot of error message.

Is it a bug or I missed something?

-- 
GNU Powered it
GPL Protected it
GOD Blessed it

HFG - NalaGinrut

--hacker key--
v4sw7CUSMhw6ln6pr8OSFck4ma9u8MLSOFw3WDXGm7g/l8Li6e7t4TNGSb8AGORTDLMen6g6RASZOGCHPa28s1MIr4p-x hackerkey.com
---end key---




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-31 23:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-20  3:55 can't use variable in sxml-match? Ian Price
2011-05-20  5:17 ` nalaginrut
2011-05-31 22:01 ` Ludovic Courtès
2011-05-31 23:56   ` nalaginrut
  -- strict thread matches above, loose matches on Subject: below --
2011-05-20  1:06 nalaginrut
2011-05-20  2:26 ` nalaginrut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).