Re: saxon-help Digest, Vol 124, Issue 11

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: saxon-help Digest, Vol 124, Issue 11

France Baril
Ok, thanks. I'll wait for sourceNode. My content is built from a DB, I don't have a location to provide. 

On Mon, Oct 24, 2016 at 2:46 AM, <[hidden email]> wrote:
Send saxon-help mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/saxon-help
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of saxon-help digest..."


Today's Topics:

   1. Saxon-JS with sourceNode: issue with object type used?
      (France Baril)
   2. Re: Saxon-JS with sourceNode: issue with object type used?
      (Martin Honnen)
   3. Re: Saxon-JS with sourceNode: issue with object type used?
      (Martin Honnen)
   4. Re: Saxon-JS with sourceNode: issue with object type used?
      (Debbie)


----------------------------------------------------------------------

Message: 1
Date: Fri, 21 Oct 2016 16:23:05 -0700
From: France Baril <[hidden email]>
Subject: [saxon] Saxon-JS with sourceNode: issue with object type
        used?
To: [hidden email]
Message-ID:
        <CAHNQ2BYkXmNp=[hidden email]>
Content-Type: text/plain; charset="utf-8"

I can get everything to work with sourceLocation as an input, but not with
sourceNode.

Here are the relevant pieces of code. I left my tests in comments. My best
guess is that I am not using the right type of js object, but all my trials
failed. It might be useful to have an example that uses sourceNode in the
documentation.

?JS

$.get(req).done(*function*(data){
         alert(data);
         //var xmlDoc = $.parseXML(data),
         //xml = $(xmlDoc).get(0);
         //xml = $(xmlDoc).find('title').first();

         // Trying as non-jquery object
         *var* parser = *new* DOMParser(),
          xmlObject = parser.parseFromString(data , "text/xml");
          *var* xml = xmlObject.getElementById('template-post-event');
          alert(xml.nodeName + ': ' + xml.nodeType);
         SaxonJS.transform({
           stylesheetLocation: "/static/sef/test-sx.sef",
           sourceNode: xml,
           //initialTemplate: 'main',
           //sourceLocation: '/static/test/test.xml',
           deliverMessage: *function*(data){console.log('xsl:message: Nav '
+ data)}
         });
         //alert(html);
         //$(divId).html(html);
      }, 'string').fail(*function* (err) {
            alert ('Error. Could not load topic: ' + err.responseText)
      });


XSLT? start point (Important errors are in yellow):

<xsl:template match="/" name="main">
         <xsl:message>In main</xsl:message>
         <!--  This works in my web application with initialTemplate =
'main' -->
         <!--xsl:result-document href="#get-xml-topic"
method="ixsl:replace-content">
            <div>Hello Saxon-JS</div>
         </xsl:result-document-->

         <!-- This works outside the context of the application -->
         <!--xsl:apply-templates></xsl:apply-templates-->

         <!-- This works with sourceLocation in my web application, but not
with sourceNode -->
         <!-- When initialTemplate is specified, I get an error about a
missing context on apply-template -->
         <!-- When initialTemplate is NOT specified, I am told that no
source document, initial template or mode is provided -->
         <xsl:result-document href="#get-xml-topic" method=
"ixsl:replace-content">
               <xsl:apply-templates></xsl:apply-templates>
         </xsl:result-document>
   </xsl:template>




--
France Baril
Architecte documentaire / Documentation architect
[hidden email]
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

Message: 2
Date: Sat, 22 Oct 2016 10:36:02 +0200
From: Martin Honnen <[hidden email]>
Subject: Re: [saxon] Saxon-JS with sourceNode: issue with object type
        used?
To: Mailing list for the SAXON XSLT and XQuery processor
        <[hidden email]>
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=windows-1252; format=flowed

On 22.10.2016 01:23, France Baril wrote:
> *var* xml = xmlObject.getElementById('template-post-event');


Does that call find a node? getElementById with XML only works with
attributes defined as ID in the DTD (and most browsers only support
internal DTD subsets), are you doing that in your XML?



------------------------------

Message: 3
Date: Sun, 23 Oct 2016 14:10:00 +0200
From: Martin Honnen <[hidden email]>
Subject: Re: [saxon] Saxon-JS with sourceNode: issue with object type
        used?
To: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=windows-1252; format=flowed

On 22.10.2016 10:36, Martin Honnen wrote:
> On 22.10.2016 01:23, France Baril wrote:
>> *var* xml = xmlObject.getElementById('template-post-event');
>
>
> Does that call find a node? getElementById with XML only works with
> attributes defined as ID in the DTD (and most browsers only support
> internal DTD subsets), are you doing that in your XML?

My comment does not seem to appear relevant to the problem, it simply
seems that the Saxon-JS beta does not take into account the sourceNode
or sourceText properties of the options argument to the transform method
when run in the browser, the relevant lines in SaxonJS.js are

         if (inBrowser) {
             if (options.stylesheetLocation === undefined) {
                 throw "No stylesheet supplied";
             }
             platform.asyncGetMultipleXml([options.stylesheetLocation,
options.sourceLocation], function (docs) {
                 stylesheet = docs[options.stylesheetLocation] /*||
options.stylesheetNode*/;
                 sourceDoc = docs[options.sourceLocation] /*||
options.sourceNode*/;
                 applyStylesheet(stylesheet, sourceDoc, options);
                 if (callback) {
                     callback(options.principalResult);
                 }
             })
         }

so the access to options.sourceNode is commented out.





------------------------------

Message: 4
Date: Mon, 24 Oct 2016 10:50:03 +0100
From: Debbie <[hidden email]>
Subject: Re: [saxon] Saxon-JS with sourceNode: issue with object type
        used?
To: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="utf-8"

Apologies France, you're right that currently you can only supply a
source document using sourceLocation. Martin's assessment is correct:
currently the sourceNode transform property is not implemented for use
within the browser. It should not be in the documentation yet.

We do intend to get the sourceNode option working in the future, and
then the code you tried should work.

Martin has now raised a bug for this, so you can keep track of progress
there: https://saxonica.plan.io/issues/3007

Hopefully we can get this fixed for the next beta release.


On 22.10.2016 10:36, Martin Honnen wrote:

> On 22.10.2016 01:23, France Baril wrote:
>> *var*  xml = xmlObject.getElementById('template-post-event');
> Does that call find a node? getElementById with XML only works with
> attributes defined as ID in the DTD (and most browsers only support
> internal DTD subsets), are you doing that in your XML?

My comment does not seem to appear relevant to the problem, it simply
seems that the Saxon-JS beta does not take into account the sourceNode
or sourceText properties of the options argument to the transform method
when run in the browser, the relevant lines in SaxonJS.js are

          if (inBrowser) {
              if (options.stylesheetLocation === undefined) {
                  throw "No stylesheet supplied";
              }
              platform.asyncGetMultipleXml([options.stylesheetLocation,
options.sourceLocation], function (docs) {
                  stylesheet = docs[options.stylesheetLocation] /*||
options.stylesheetNode*/;
                  sourceDoc = docs[options.sourceLocation] /*||
options.sourceNode*/;
                  applyStylesheet(stylesheet, sourceDoc, options);
                  if (callback) {
                      callback(options.principalResult);
                  }
              })
          }

so the access to options.sourceNode is commented out.



On 22/10/2016 00:23, France Baril wrote:
> I can get everything to work with sourceLocation as an input, but not
> with sourceNode.
>
> Here are the relevant pieces of code. I left my tests in comments. My
> best guess is that I am not using the right type of js object, but all
> my trials failed. It might be useful to have an example that uses
> sourceNode in the documentation.
>
> ?JS
>
> $.get(req).done(*function*(data){
>          alert(data);
> //var xmlDoc = $.parseXML(data),
> //xml = $(xmlDoc).get(0);
> //xml = $(xmlDoc).find('title').first();
>
> // Trying as non-jquery object
> *var* parser = *new* DOMParser(),
>           xmlObject = parser.parseFromString(data , "text/xml");
> *var* xml = xmlObject.getElementById('template-post-event');
>           alert(xml.nodeName + ': ' + xml.nodeType);
>          SaxonJS.transform({
>            stylesheetLocation: "/static/sef/test-sx.sef",
>            sourceNode: xml,
> //initialTemplate: 'main',
> //sourceLocation: '/static/test/test.xml',
>            deliverMessage: *function*(data){console.log('xsl:message:
> Nav ' + data)}
> });
> //alert(html);
> //$(divId).html(html);
> }, 'string').fail(*function* (err) {
>             alert ('Error. Could not load topic: ' + err.responseText)
> });
>
>
>
> XSLT? start point (Important errors are in yellow):
>
> <xsl:templatematch="/"name="main">
> <xsl:message>In main</xsl:message>
> <!--  This works in my web application with initialTemplate = 'main' -->
> <!--xsl:result-document href="#get-xml-topic"
> method="ixsl:replace-content">
>             <div>Hello Saxon-JS</div>
>          </xsl:result-document-->
>
> <!-- This works outside the context of the application -->
> <!--xsl:apply-templates></xsl:apply-templates-->
>
> <!-- This works with sourceLocation in my web application, but not
> with sourceNode -->
> <!-- When initialTemplate is specified, I get an error about a missing
> context on apply-template -->
> <!-- When initialTemplate is NOT specified, I am told that no source
> document, initial template or mode is provided -->
> <xsl:result-documenthref="#get-xml-topic"method="ixsl:replace-content">
> <xsl:apply-templates></xsl:apply-templates>
> </xsl:result-document>
> </xsl:template>
>
>
>
>
>
> --
> France Baril
> Architecte documentaire / Documentation architect
> [hidden email] <mailto:[hidden email]>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help

--
Debbie Lockett
Saxonica

-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

------------------------------

_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
The saxon-help list is archived at http://saxon.markmail.org/

End of saxon-help Digest, Vol 124, Issue 11
*******************************************



--
France Baril
Architecte documentaire / Documentation architect
[hidden email]


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Loading...