On Thu, 2014-03-27 at 17:06 +0000, Rushforth, Peter wrote:
[...]
What I came up seems to work ok:
<xsl:function name="ex:locationJson2Options">
<xsl:param name="json"/><!-- 1 2
3 4 5 6
7 8 9 10 11 12 13
14 15 16 17
-->
<xsl:variable name="regexps"
select="'(\{.*?("title":.*?"(.*?)").*?("qualifier":.*?"(.*?)").*?("type":.*?"(.*?)").*?(((("bbox":.*?\[(.*?)\]).*?("geometry":.*?(\{.*?\})).*?\}{1,}))|(("geometry":.*?(\{.*?\})).*?\}{1,})))'"/>
<xsl:analyze-string select="$json" regex="{$regexps}" flags="s">
[...]
I am glad it didn't lead to madness, [...]
It's subject to debate :-)
For example,
"title" : "The \"liteness\" of Bering: a sales qualifier"
will probably fail.; that may or may not matter for you.
One way to deal with \ would be to replace \" with some unicode string
that you first checked didn't appear, and then your expression (modulo
putting \s in there instead of .* in places) would be simpler.
I'd also note you use " a lot, so change them to " and use '....'
and ' instead. You can also build up a complex expression by making
smaller variables (with comments) and using concat() at the end.
Liam
--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--