xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Fuqua <samfu...@gmail.com>
Subject Re: fop + json
Date Tue, 19 May 2009 17:20:28 GMT
Andreas,

Thank you for such a quick and clear reply.  I will try to find a way to
parse the json elsewhere.

Sam

On Tue, May 19, 2009 at 1:16 PM, Andreas Delmelle <
andreas.delmelle@telenet.be> wrote:

> On 19 May 2009, at 19:05, Sam Fuqua wrote:
>
> Hi Sam
>
>
>  I know that this isn't within the bounds of the w3 standard, but I was
>> wondering if FOP has any way of handling JSON.
>> For example, if I have:
>> <root>
>> <element>
>> {"menu":{"key":"value","id":"idnum"}}
>> </element>
>> </root>
>> , is there any way to xpath into the JSON in the text node?  I've seen it
>> used in another xml parser, but wasn't sure if it's possible to reference
>> element/menu/id in my XSL when I'm creating an FO document.
>>
>
> Not possible with FOP, I'm afraid, since JSON is Javascript, and unrelated
> to XML.
> To a general XML parser, the content of the element node is simply a text
> node. FOP has no embedded script engine to parse and evaluate it as a
> Javascript object.
>
> The only way to get the value of the 'id' attribute of the object in
> standard XML/XSLT would thus be using something like:
>  substring-before(substring-after(/root/element,'"id":"'),'"}')
>
> Another route would be to translate the JSON object to XML, parse it as
> such, and then use normal XPath to get the requested attribute from
> something like:
>
> <root><element><menu key="value" id="idnum" /></element></root>
> or
> <root><element><menu><key>value</key><id>idnum</id></menu></element></root>
>
> Regards
>
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>


-- 
Sam Fuqua
ΣΝ ΘΗ 454

Mime
View raw message