Re: [Saxon-JS 2] Creating a JSON object
Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]>
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <[email protected]> |
I can't see why you want to create an attribute in order to extract its string value. Why not just construct the string in the first place?
<xsl:variable name="js-statement" as="xs:string"
select="{ subject: SPARQLBuilder.SelectBuilder.var('child'),
predicate: SPARQLBuilder.SelectBuilder.var(' || $predicate || '),
object: SPARQLBuilder.SelectBuilder.var('whatever') }"/>
Apart from that, if you really need to write the application by generating Javascript dynamically and then evaluating it, then I don't think it's going to much simpler than this. But I can't really judge whether that is actually the right design.
Michael Kay
Saxonica
> "
> select="ixsl:eval()"/>
> On 4 Sep 2020, at 21:39, Martynas Jusevičius <[email protected]> wrote:
>
> Hi,
>
> Is there a quicker/cleaner way to create a JSON object and store it in
> a variable than this?
>
> <xsl:variable name="js-statement" as="element()">
> <root statement="{{ subject:
> SPARQLBuilder.SelectBuilder.var('child'), predicate:
> SPARQLBuilder.SelectBuilder.var('{$predicate}'), object:
> SPARQLBuilder.SelectBuilder.var('whatever') }}"/>
> </xsl:variable>
> <xsl:variable name="bgp"
> select="ixsl:eval(string($js-statement/@statement))"/>
>
> $bgp is later being used like this:
>
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help