Benoit Maisonny wrote: > > I'm developing a custom implementation of XInclusion.
Unfortunately we cannot provide support for this kind of advanced extensions. We know that XInclusion is part of the public API, but in practice, we provide support only for the extensions documented in "XMLmind XML Editor - Developer's Guide" (http://www.xmlmind.com/xmleditor/_distrib/doc/dev/index.html). If you really need to develop a custom implementation of XInclusion, then you'll have to read the source code of XXE (included in the xe-site and xe-dev distributions, available on request for customers having purchased 10 xe-usr licenses or more). Alternatively, you can hire us to do it. See http://www.xmlmind.com/xmleditor/customization_service.html > When opening in > XXE a file containing my custom include element, I get the following error: > file:[some file URI here]::: inclusion implementation error: missing > source URL > > I load the target file using: > context.getDocument(url); > context is the XInclusionContext passed to the method XInclusion.include(). > > I thought I might need to set SOURCE_URL_PROPERTY myself, so I tried: > doc.putProperty(Constants.SOURCE_URL_PROPERTY, url); > right after the line above, but the result is the same: the error > message above. > > What should I do to provide that source URL? According to the doc http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xml/load/XInclusion.html#include(com.xmlmind.xml.doc.Node,%20com.xmlmind.xml.doc.Node,%20boolean,%20com.xmlmind.xml.load.XInclusionContext) --- Node[] include(Node firstNode, Node lastNode, boolean updating, XInclusionContext context) throws InclusionException returns a non-empty array containing included nodes. Included nodes are copies of some ``original nodes''. These copies are not always clones of the original nodes (e.g. DITA conref). The returned nodes must each have a Constants.SOURCE_URL_PROPERTY property properly set. On the other hand, adding the Constants.INCLUSION_PROPERTY and Constants.READ_ONLY_PROPERTY properties to returned nodes is not useful. --- Therefore, you need to invoke putProperty(Constants.SOURCE_URL_PROPERTY, XXX) on each node returned by include() and not on doc like you did it. Excerpt of src/com/xmlmind/xml/xinclude/XInclude.java: --- public Node[] include(Node firstNode, Node lastNode, boolean updating, XInclusionContext context) throws InclusionException { Node[] nodes = null; if (parseText) { String text; try { text = loadText(href, textEncoding); } catch (IOException e) { throw new InclusionException( Msg.msg("cannotLoadText", href, ThrowableUtil.reason(e))); } Node copy = new Text(text); copy.putProperty(SOURCE_URL_PROPERTY, href); nodes = new Node[] { copy }; } else { ... --- > And what if the included nodes are built on request and don't come from > an actual source document? In theory, an XInclusion (but not a SimpleInclusion) allows to do this. However, we currently have no implementation of an XInclusion which is not also a SimpleInclusion. Therefore, XXE probably has design and/or implementation and/or documentation bugs related to the support of ``pure XInclusions''. References: * http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xml/load/XInclusion.html * http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xml/load/SimpleInclusion.html

