[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Saxon-CE -- Passing Data to a JS Function

Subject: Saxon-CE -- Passing Data to a JS Function
From: "Chris Despopoulos despopoulos_chriss@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Jul 2016 12:28:07 -0000
 Saxon-CE -- Passing Data to a JS Function
First, apologies for my status as an XSLT user.B  I know enough to be
dangerous, but not enough to understand how or why!B  I'm working on it (Yes,
I have the big book by Dr. Kay).
I'm trying to use Saxon-CE for DITA to HTML transforms in the browser (instead
of the browser's XSLT engine).B  I definitely need to pass JSON data to JS
functions.B  I would like to pass generated HTML to JS functions as well, but
I might be able to make the result-document mechanism work for my existing
app.B  (Looking into that -- Heck, it might beB  superior to passing HTML as a
string.B  What's important is being able to inject data from the product API
as I generate the result.B  I'm guessing Saxon-CE can do that.)

Anyway, I originally had problems passing data to JS, but I've got the JSON
part working.B  The trick is getting a string into a variable -- Then I can
pass that easily enough.B  (Thanks for the help so far!!!)
For example, for this XML:

I can get this string into an alert...{foo : arf, bar : content:"
B B B 

B B B 

B B B 

B B B  "}

Sure would like to get rid of the extra line returns, but that's lower
priority.B  Declaring the variable as a string and copying the results into
the variable seems to do the trick.B  A question is...B  How would I generate
HTML and copy THAT into a variable that I can pass to JS?B  I suspect that JS
is ignorant of XSLT tree objects...
<advance>Thanks</advance>B  (Thanks in advance for any help)

Here's the XSLT that I use to make the JSON string.B  Is this more or less the
transform structure you would use -- Global variable populated by named
template (or maybe templates of a mode???), call the function for the doc
node, and match the input XML structure in all the other templates?

<xsl:variable name="myTree" as="xs:string"><xsl:call-template

<xsl:template match="/"><xsl:call-template name="callFunc" /></xsl:template>

<xsl:template match="items/item">&lt;p&gt;<xsl:value-of

<xsl:template name="TRY_THIS">
<xsl:copy>{foo : arf, bar : content:" <xsl:apply-templates/>B B B 

<xsl:template name="callFunc"><xsl:value-of

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.