Load documents from a pseudo protocol
Xopus supports URI's to identify XML content. When a URI is relative, Xopus will try to make it absolute. To prevent that in cases where you want to use a virtual identifier (in the case where you are loading the document not from a url as a file but in some other way, like from a form field), you will need to make it absolute by use of a pseudo protocol.
<p>
<textarea id="textarea1"><document/></textarea>
</p>
<div xopus="true">
<xml>
<x:config version="1.0" xmlns:x="http://www.xopus.com/xmlns/config">
<x:pipeline xml="textarea1"/>
<x:javascript>
IO.setLoadXMLFunction(function (uri) {
var src = document.getElementById(uri).value;
return Editor.XML.createNativeXMLDocument(src);
});
</x:javascript>
</x:config>
</xml>
</div>
Instead use:
…
<x:pipeline xml="form:textarea1"/>
<x:javascript>
IO.setLoadXMLFunction(function (uri) {
var match = /^form:(.+)$/.exec(uri);
if (!match)
return;
var src = document.getElementById(match[1]);
return Editor.XML.createNativeXMLDocument(src);
});
</:javascript>
…
Then "form:textarea1" is passed to your load handler instead of a resolved path ending with textarea1.
- Documentation
- › How To
- › Load documents from a pseudo protocol