[racket-users] XML Modification

2016-12-14 Thread Lehi Toskin
I have some XML - rather, XMP data from an image - that I'd like to mess around 
with. I've investigated the xml library and found that I can turn the XML into 
an XEXPR so I can play around with it like that and even search through it with 
se-path*/list, but how would I go from there to replacing parts of the XEXPR? 
By my reckoning, I'd need to scan through the list and locate the data I want 
and then do something like list-set, but searching through an XEXPR that can 
have many nested sublists sounds like a nightmare to program for.

I suppose I could take a look at the XML string and do a regexp-match or 
something similar, but that seems inelegant and almost brute-force-y.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] XML Modification

2016-12-14 Thread Matthew Butterick

> On Dec 14, 2016, at 3:04 PM, Lehi Toskin  wrote:
> 
> I have some XML - rather, XMP data from an image - that I'd like to mess 
> around with. I've investigated the xml library and found that I can turn the 
> XML into an XEXPR so I can play around with it like that and even search 
> through it with se-path*/list, but how would I go from there to replacing 
> parts of the XEXPR? By my reckoning, I'd need to scan through the list and 
> locate the data I want and then do something like list-set, but searching 
> through an XEXPR that can have many nested sublists sounds like a nightmare 
> to program for.


My `txexpr` library has some higher-level utilities for working with 
complicated X-expressions.

http://docs.racket-lang.org/txexpr/ 


Also see `pollen/decode`, which I designed for selective replacements within 
text-based X-expressions, but will work with any X-expression:

http://docs.racket-lang.org/pollen/Decode.html?q=pollen%2Fdecode 



> I suppose I could take a look at the XML string and do a regexp-match or 
> something similar, but that seems inelegant and almost brute-force-y.

That way madness lies.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] XML Modification

2016-12-14 Thread Lehi Toskin
> http://docs.racket-lang.org/txexpr/

Hoo-ray! splitf-xexpr is *exactly* what I needed. Thank you for your help!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.