Skip to content

Instantly share code, notes, and snippets.

@avernet
avernet / getElementByTagName.js
Created October 16, 2010 01:07
Study of 3 ways to implement the same function, with different programming styles
/**
* Similar to root.getElementsByTagName(tagName), but:
*
* 1. Returns root if root.tagName == tagName.
* 2. Returns only one element (the first if there are many).
* 3. Can take an array of tagName if there are alternatives.
*
* @param {Element} root Root node from which we start the search
* @param {string|Array.<string>} tagNameOrArray Tag name we're looking for
*/
@avernet
avernet / 20101227-xquery-injection.xhtml
Created December 28, 2010 00:29
How to avoid code injections when sending XQuery to eXist
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:exist="http://exist.sourceforge.net/NS/exist">
<xhtml:head>
<xhtml:title>Preventing XQuery Injections</xhtml:title>
<xforms:model>
<xforms:instance id="form">
<instance>
@avernet
avernet / gist:765277
Created January 4, 2011 19:41
Exception when sending xxforms-upload-start
<xxforms:event-request xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
<xxforms:uuid>46AFE50E-6980-6EE8-C78A-D12CF0AD57C9</xxforms:uuid>
<xxforms:sequence>2</xxforms:sequence>
<xxforms:action>
<xxforms:event name="xxforms-upload-start" source-control-id="xf-20·1"/>
</xxforms:action>
</xxforms:event-request>
java.lang.NullPointerException
at org.orbeon.oxf.xforms.XFormsContainingDocument.startUpload(XFormsContainingDocument.java:1586)
@avernet
avernet / gist:765922
Created January 5, 2011 04:21
Server events at the same time as the xxforms-upload-start
<xxforms:event-request xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
<xxforms:uuid>88F98F91-A7B9-0BE0-3065-488396E2447E</xxforms:uuid>
<xxforms:sequence>5</xxforms:sequence>
<xxforms:server-events>
X2ztnLbujs+Xq/8pkNmusI12uf7xCjfPOMLUv/qi3xGhiXSZ4bQaXbLfqLujZyMJUsoNbXovWKZYnMWIHPR7Sn320yAxM7YAC75wfoUTt2EBrXy6Gk4fOwNHg/PIUaHKRyh12fPE9CQpLAU1y9dPly+B4X3rjoj8Xxz5AcE1ta4vQ2/2M9iQrCHWEhy2E5bX+DC+Mu5op0kmK/aFI+lZcqhGXHxD/Pll9Ks16tW7cWtLErT/9eLaPAODmJXrUkWwnLazfIpm4xURwtNFe9RA7vSzsTXGe/vniHOZTRepiwXky0dnREHENMMdTPpMZ9KTVmR5yYYXZl5qHFwQyWrWIGkHgRwFEDKJO8/eYj7M2V8pa3HX2YanWbuumEC/+/HpLgS4x9AKFQqKgd6Hk1XfzRkF1/yx3D+dS5yyfoz3mJRXbyL/5+hLcPfO6SqMQlIvGIpxJnoQO2OcjUVxIs+YqXS71I94PH4bzSn0iDI1bBBvtNI1rW3ZE4uPUi6ctQbGBpWkdmG2O6swyE/zH+qLU7oWir/QOe+3cZgP5IkfsLANXu29iTT8of6LGfOt5tI7d0jmkld7IsjF/iGz+JYTtc0WwPBJSGjPFI4X6OduoxoNulzq22c8PbgMBfeq2AHTsXjgpH8Xpn7es=
</xxforms:server-events>
<xxforms:action>
<xxforms:event name="xxforms-upload-start" source-control-id="xf-20·2"></xxforms:event>
@avernet
avernet / gist:775765
Created January 12, 2011 06:13
While uploading large file
2011-01-11 23:03:36,294 INFO ProcessorService - /xforms-server - Received request
2011-01-11 23:03:36,304 DEBUG XFormsServer - ajax request {body: "
<xxforms:event-request xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
<xxforms:uuid>E7121315-1231-4234-06D5-9EC5C36BF37E</xxforms:uuid>
<xxforms:sequence>1</xxforms:sequence>
<xxforms:action>
<xxforms:event name="DOMFocusIn" source-control-id="xf-20·1"/>
<xxforms:event name="DOMFocusIn" source-control-id="file-repeat·1"/>
</xxforms:action>
</xxforms:event-request>"}
@avernet
avernet / gist:778987
Created January 14, 2011 01:23
Response with progress
<xxforms:event-request xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
<xxforms:uuid>B3DB37A7-DB4C-F774-42CB-88136E63A0D0</xxforms:uuid>
<xxforms:sequence>7</xxforms:sequence>
<xxforms:action>
<xxforms:event name="show-fb-test-dialog" source-control-id="fb-test-button-group"></xxforms:event>
</xxforms:action>
</xxforms:event-request>
<xxf:event-response xmlns:xxf="http://orbeon.org/oxf/xml/xforms">
<xxf:action>
@avernet
avernet / README.md
Created January 18, 2011 23:38
Bookmarklet detecting if a page uses automatically generated ids

Bookmarklet detecting if a page uses automatically generated ids

Purpose

When producing HTML markup from XForms, Orbeon Forms automatically generates ids if your XForms doesn't contain ids. If you reload the same page twice, the ids produced by Orbeon Forms will be the same. However, if you upgrade to a newer version of Orbeon Forms, those ids could be different, which might be an issue for you if you have automated tests that depend on those ids. You can avoid this issue by making sure you always specify ids in your XForms, and this bookmarklet helps you to check that a given page doesn't contain any automatically generated id.

<!--
Copyright (C) 2006 Orbeon, Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU Lesser General Public License as published by the Free Software Foundation; either version
2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
<xhtml:head>
<xhtml:title>XForms Inspector update test case</xhtml:title>
<xforms:model>
<xforms:instance>
@avernet
avernet / gist:803780
Created January 31, 2011 08:36
XForms Hello, in Haml
%xh:html{ "xmlns:xh" => "http://www.w3.org/1999/xhtml",
"xmlns:xf" => "http://www.w3.org/2002/xforms"}
%xh:head
%xh:title XForms Hello
%xf:model
%xf:instance
%first-name
%xh:body
%xh:p
%xh:i