Hi again,

I've created a test-case so that it is easier to answer my question.

The included files are a XForms application. So, for this test-case to
work, you need to download XSLTForms from the "XML Data Island" branch,
with the following svn command:

svn -r 448 co
https://xsltforms.svn.sourceforge.net/svnroot/xsltforms/branches/dataisland
xsltforms-data-island-448

Put the attached files "test-chrome-xslt.xml" and "test-chrome-xslt.js"
in the directory containing the "xsltforms-data-island-448" directory.
Then open the file in both Firefox and in a WebKit based browser (it
seems necessary to open the file through a local web server with WebKit,
otherwise you get a blank white screen).

In the debugger, add a watch expression on
"myInstance.childNodes[0].childNodes", and put a breakpoint on line 12
of "test-chrome-xslt.js".

Then click in the drop-down menu. You will see:
0:Element
1:Element
2:Element
3:Element
4:Element
which is normal because it is before the sorting.

After a second click in the drop-down menu, you will see:
0:Element
1:HTMLElement
2:HTMLElement
3:HTMLElement
4:HTMLElement

And then everything will disappear because "transformToFragment" (line
20) doesn't seem able to work with "HTMLElement"s.

If this is a bug, please tell me and I will fill a bug report.

Regards,
Gregoire

Le 12/09/2010 13:29, Gregoire a écrit :
> Hi,
> 
> I'm trying to sort a XML Data Island using XSLTProcessor. My XSL is:
> 
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns="">
>   <xsl:output method="xml" encoding="utf-8"
>               omit-xml-declaration="yes" indent="no"/>
>   <xsl:strip-space elements="*"/>
>   <xsl:template match="/dummy">
>     <xsl:apply-templates select="announce[position() > 1]">
>       <xsl:sort data-type="number" select="price" order="ascending"/>
>     </xsl:apply-templates>
>   </xsl:template>
>   <xsl:template match="*|@*|text()">
>     <xsl:copy>
>       <xsl:apply-templates select="*|text()|@*"/>
>     </xsl:copy>
>   </xsl:template>
> </xsl:stylesheet>
> 
> As you can see, I use the method="xml" attribute in <xsl:output>. In
> Firefox, using method="xml" returns Element nodes and the program works
> as expected (I can sort any number of times the XML Data Island).
> 
> However, WebKit's implementation of "requestToFragment" seems to always
> return HTMLElement nodes, and after the first sort which works ok (but
> transforms my Elements to HTMLElements), it always return an empty
> nodeset (as if HTMLElements weren't found by the above XSL).
> 
> Is it possible to tell WebKit's XSLTProcessor to return Elements instead
> of HTMLElements? If so, what could be the problem with my XSL stylesheet?
> 
> Thanks!
> Gregoire

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="xsltforms-data-island-448/build/xsltforms.xsl" type="text/xsl"?>
<?xsltforms-options debug="no"?>
<?css-conversion no?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:xf="http://www.w3.org/2002/xforms";
      xmlns:ev="http://www.w3.org/2001/xml-events";
>
<head>
  <title>WebKit's XSLTProcessor transformToFragment test case</title>

  <script type="text/javascript" src="test-chrome-xslt.js"/>

  <xf:model id="model-announces">
    <xf:instance id="instance-announces">
      <dummy xmlns="">
        <announce>
          <id>PROTOTYPE</id>
        </announce>
        <announce>
          <id>ANNONCE-1</id>
          <price>100</price>
        </announce>
        <announce>
          <id>ANNONCE-2</id>
          <price>50</price>
        </announce>
        <announce>
          <id>ANNONCE-3</id>
          <price>200</price>
        </announce>
        <announce>
          <id>ANNONCE-4</id>
          <price>150</price>
        </announce>
      </dummy>
    </xf:instance>

    <xf:instance id="instance-stylesheet">
      <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns="">
        <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="no"/>
        <xsl:strip-space elements="*"/>
        <xsl:template match="/dummy">
          <xsl:apply-templates select="announce[position() > 1]">
            <xsl:sort data-type="number" select="price" order="ascending"/>
          </xsl:apply-templates>
        </xsl:template>
        <xsl:template match="*|@*|text()">
          <xsl:copy>
            <xsl:apply-templates select="*|text()|@*"/>
          </xsl:copy>
        </xsl:template>
      </xsl:stylesheet>
    </xf:instance>

    <xf:action ev:event="xforms-ready">
      <xf:load resource="javascript:window.sortHandler = new SortHandler();" />
    </xf:action>
  </xf:model>

</head>
<body>
  <p>instance-announces</p>
  <table style="text-align:center;width:300px;border:1px solid black;border-collapse:collapse">
    <thead>
      <tr>
        <th>Id</th>
        <th>price</th>
      </tr>
    </thead>
    <tbody>
      <xf:repeat nodeset="instance('instance-announces')/announce">
        <tr>
          <td style="border:1px solid black"><xf:output ref="id" model="model-announces"/></td>
          <td style="border:1px solid black"><xf:output ref="price" model="model-announces"/></td>
        </tr>
      </xf:repeat>
    </tbody>
  </table>
  <p>Sort by 'price' :
    <xf:select1 appearance="minimal" ref="instance('instance-stylesheet')//xsl:sort/@order">
      <xf:item>
        <xf:label>Ascending</xf:label>
        <xf:value>ascending</xf:value>
      </xf:item>
      <xf:item>
        <xf:label>Descending</xf:label>
        <xf:value>descending</xf:value>
      </xf:item>
      <xf:load resource="javascript:window.sortHandler.sortInstance('instance-announces')" ev:event="xforms-value-changed"/>
    </xf:select1>
  </p>
</body>
</html>

Attachment: test-chrome-xslt.js
Description: application/javascript

_______________________________________________
webkit-help mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-help

Reply via email to