Library: sarissa.js
Constructors
Sarissa is a utility class. Provides "static" methods for DOMDocument,
DOM Node serialization to XML strings and other utility goodies.
methods
An implementation of Mozilla's XSLTProcessor for IE.
Reuses the same XSLT stylesheet for multiple transforms
methods
Utility class to serialize DOM Node objects to XML strings
methods
Functions
Imports the given XSLT DOM and compiles it to a reusable transform
Note: If the stylesheet was loaded from a URL and contains xsl:import or xsl:include elements,it will be reloaded to resolve those
parameters
|
|
xslDoc
|
The XSLT DOMDocument to import
|
Transform the given XML DOM and return the transformation result as a new DOM document
parameters
|
|
sourceDoc
|
The XML DOMDocument to transform
|
returns
|
|
The transformation result as a DOM Document
|
Transform the given XML DOM and return the transformation result as a new DOM fragment.
Note: The xsl:output method must match the nature of the owner document (XML/HTML).
parameters
|
|
sourceDoc
|
The XML DOMDocument to transform
|
|
|
ownerDoc
|
The owner of the result fragment
|
returns
|
|
The transformation result as a DOM Document
|
Set global XSLT parameter of the imported stylesheet
parameters
|
|
nsURI
|
The parameter namespace URI
|
|
|
name
|
The parameter base name
|
|
|
value
|
The new parameter value
|
Gets a parameter if previously set by setParameter. Returns null
otherwise
parameters
|
|
name
|
The parameter base name
|
|
|
value
|
The new parameter value
|
returns
|
|
The parameter value if reviously set by setParameter, null otherwise
|
Clear parameters (set them to default values as defined in the stylesheet itself)
Factory method to obtain a new DOM Document object
parameters
|
|
sUri
|
the namespace of the root node (if any)
|
|
|
sUri
|
the local name of the root node (if any)
|
returns
Construct a new DOM Document from the given XMLstring
parameters
|
|
sXml
|
the given XML string
|
|
|
contentType
|
the content type of the document the given string represents (one of text/xml, application/xml, application/xhtml+xml).
|
returns
|
|
a new DOM Document from the given XML string
|
document.importNode(
oNode, bChildren)
Implementation of importNode for the context window document in IE.
If oNode is a TextNode, bChildren is ignored.
parameters
|
|
oNode
|
the Node to import
|
|
|
bChildren
|
whether to include the children of oNode
|
returns
|
|
the imported node for further use
|
Returns a human readable description of the parsing error. Usefull
for debugging. Tip: append the returned error string in a <pre>
element if you want to render it.
Many thanks to Christian Stocker for the initial patch.
parameters
|
|
oDoc
|
The target DOM document
|
returns
|
|
The parsing error description of the target Document in
human readable form (preformated text)
|
Get a string with the concatenated values of all string nodes under the given node
parameters
|
|
oNode
|
the given DOM node
|
|
|
deep
|
whether to recursively scan the children nodes of the given node for text as well. Default is false
|
Serialize the given DOM Node to an XML string
parameters
|
|
oNode
|
the DOM Node to serialize
|
Strips tags from the given markup string
parameters
Deletes all child nodes of the given node
parameters
Sarissa.copyChildNodes(
nodeFrom, nodeTo, bPreserveExisting)
Copies the childNodes of nodeFrom to nodeTo
Note: The second object's original content is deleted before
the copy operation, unless you supply a true third parameter
parameters
|
|
nodeFrom
|
the Node to copy the childNodes from
|
|
|
nodeTo
|
the Node to copy the childNodes to
|
|
|
bPreserveExisting
|
whether to preserve the original content of nodeTo, default is false
|
Sarissa.moveChildNodes(
nodeFrom, nodeTo, bPreserveExisting)
Moves the childNodes of nodeFrom to nodeTo
Note: The second object's original content is deleted before
the move operation, unless you supply a true third parameter
parameters
|
|
nodeFrom
|
the Node to copy the childNodes from
|
|
|
nodeTo
|
the Node to copy the childNodes to
|
|
|
bPreserveExisting
|
whether to preserve the original content of nodeTo, default is
|
Serialize any non DOM object to an XML string. All properties are serialized using the property name
as the XML element name. Array elements are rendered as array-item elements,
using their index/key as the value of the key attribute.
parameters
|
|
anyObject
|
the object to serialize
|
|
|
objectName
|
a name for that object
|
returns
|
|
the XML serialization of the given object as a string
|
Escape the given string chacters that correspond to the five predefined XML entities
parameters
|
|
sXml
|
the string to escape
|
Unescape the given string. This turns the occurences of the predefined XML
entities to become the characters they represent correspond to the five predefined XML entities
parameters
|
|
sXml
|
the string to unescape
|
Sarissa.updateContentFromURI(
sFromUrl, oTargetElement, xsltproc, callback, skipCache)
Asynchronously update an element with response of a GET request on the given URL. Passing a configured XSLT
processor will result in transforming and updating oNode before using it to update oTargetElement.
You can also pass a callback function to be executed when the update is finished. The function will be called as
functionName(oNode, oTargetElement);
parameters
|
|
sFromUrl
|
the URL to make the request to
|
|
|
oTargetElement
|
the element to update
|
|
|
xsltproc
|
(optional) the transformer to use on the returned
content before updating the target element with it
|
|
|
callback
|
(optional) a Function object to execute once the update is finished successfuly, called as callback(oNode, oTargetElement)
|
|
|
skipCache
|
(optional) whether to skip any cache
|
Sarissa.updateContentFromNode(
oNode, oTargetElement, xsltproc, callback)
Update an element's content with the given DOM node. Passing a configured XSLT
processor will result in transforming and updating oNode before using it to update oTargetElement.
You can also pass a callback function to be executed when the update is finished. The function will be called as
functionName(oNode, oTargetElement);
parameters
|
|
oNode
|
the URL to make the request to
|
|
|
oTargetElement
|
the element to update
|
|
|
xsltproc
|
(optional) the transformer to use on the given
DOM node before updating the target element with it
|
|
|
callback
|
(optional) a Function object to execute once the update is finished successfuly, called as callback(oNode, oTargetElement)
|
Creates an HTTP URL query string from the given HTML form data
parameters
Sarissa.updateContentFromForm(
oForm, oTargetElement, xsltproc, callback, skipCache)
Asynchronously update an element with response of an XMLHttpRequest-based emulation of a form submission.
The form action and
method attributess will be followed. Passing a configured XSLT processor will result in
transforming and updating the server response before using it to update the target element.
You can also pass a callback function to be executed when the update is finished. The function will be called as
functionName(oNode, oTargetElement);
Here is an example of using this in a form element:
<form action="/my/form/handler" method="post"
onbeforesubmit="return Sarissa.updateContentFromForm(this, document.getElementById('targetId'));">
If JavaScript is supported, the form will not be submitted. Instead, Sarissa will
scan the form and make an appropriate AJAX request, also adding a parameter
to signal to the server that this is an AJAX call. The parameter is
constructed as Sarissa.REMOTE_CALL_FLAG = "=true" so you can change the name in your webpage
simply by assigning another value to Sarissa.REMOTE_CALL_FLAG. If JavaScript is not supported
the form will be submitted normally.
parameters
|
|
oForm
|
the form submition to emulate
|
|
|
oTargetElement
|
the element to update
|
|
|
xsltproc
|
(optional) the transformer to use on the returned
content before updating the target element with it
|
|
|
callback
|
(optional) a Function object to execute once the update is finished successfuly, called as callback(oNode, oTargetElement)
|
|
|
skipCache
|
(optional) whether to skip any cache
|
Objects