Rendering include content in DocBook
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Rendering include content in DocBook
Post by manojdcoder »
I have similar issues with DocBook (include) now. I have something like below in my document
Code: Select all
<xi:include xpointer="elementid" href="filename.xml"/>
The logs read
Code: Select all
199977 WARN [ http-nio-8080-exec-10 ] ro.sync.servlet.RESTDocumentManager - Error while loading document: System ID: https://localhost:25608/Editor?ComponentId=id&Token=authtoken
Severity: warning
Description: An 'include' failed, and no 'fallback' element was found.
[1] topic22151.html
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
Can you show some light on this one please?
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Rendering include content in DocBook
Post by cristi_talau »
I managed to reproduce your problem in a test case. It seems that the XML parser that we use handles xi:include resolution and it does not invoke the URIResolver. The URIResolver hit that you got was to generate the target for the link icon rendered near the xi:include element. I registered an issue to use the URIResolver also in this case, but is not yet scheduled.
I think that a more robust solution would be to follow the approach described here [1].
If you want a simplified version, you can try to encode the auth token in the "userInfo" part of the URL.
For example, instead of "https://localhost:25608/Editor?Componen ... =authtoken" use an URL like "custom-https://authtoken@localhost:25608/Editor?ComponentId=id". Now, if you implement an URLStreamHandler for "custom-https", you should be able to make the same requests as before, but you do not depend on URIResolver to be invoked for every URL used by the application.
Another possible path would be to use "ro.sync.exml.workspace.api.util.XMLUtilAccess.addPriorityEntityResolver(EntityResolver)" to register an EntityResolver. This EntityResolver is called after the xi:include target is resolved (without using the URIResolver). If you use an URL like: "https://authtoken@localhost:25608/Edito ... =authtoken", the EntityResolver will receive ""https://authtoken@localhost:25608/included.xml" and now you should have all the data required to construct the final URL.
[1] https://www.oxygenxml.com/doc/versions/ ... _auth.html
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
https://localhost:25608/Editor?Componen ... =authtoken is transformed to filename.xml
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
Code: Select all
pluginWorkspaceAccess.getAllEditorLocations(PluginWorkspace.MAIN_EDITING_AREA)
Code: Select all
com.oxygenxml.webauthor.SecurityManager - [OUTGOING CONNECTION] <localhost:25608> - The application tried to connect to https://localhost:25608/Editor?ComponentId=id&Token=authtoken.
27482 WARN [ http-nio-8080-exec-2 ] ro.sync.servlet.RESTDocumentManager - Error while loading document: System ID: https://localhost:25608/Editor?ComponentId=id&Token=authtoken.
Severity: warning
Description: An 'include' failed, and no 'fallback' element was found.
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Rendering include content in DocBook
Post by cristi_talau »
In my test, I tried to use inputSource.setCharacterStream() to give the content of the included file. The xi:include was resolved in this case.
Also, I think a better way to get the current editor URL is to use ro.sync.exml.workspace.api.PluginWorkspace.getCurrentEditorAccess(int) .
Best,
Cristian
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
Code: Select all
public class MyEntityResolver implements EntityResolver {
....
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
if (systemId != null) {
URL url = new URL(...); // based on systemId and editorLocation
logger.info(systemId + " ==== " + url); // url is logged as expected
InputStreamReader in = new InputStreamReader(url.openStream());
BufferedReader reader = new BufferedReader(in);
InputSource inputSource = new InputSource();
inputSource.setCharacterStream(reader);
return inputSource;
}
return null;
}
}
Also tried using getCurrentEditorAccess(int).getEditorLocation() to get editor url instead of getAllEditorLocations(int) but it throws UnsupportedOperationException
Code: Select all
URL baseUrl = pluginWorkspaceAccess.getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA)
.getEditorLocation();
Code: Select all
java.lang.UnsupportedOperationException: Method unavailable on webapp
at ro.sync.ecss.webapp.access.g.o(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.access.g.getCurrentEditorAccess(Unknown Source) ~[oxygen.jar:?]
at com.package.plugin.MyEntityResolver.resolveEntity(MyEntityResolver.java:30) ~[?:?]
at ro.sync.xml.catalogresolver.m.d(Unknown Source) ~[oxygen.jar:?]
at ro.sync.xml.catalogresolver.m.c(Unknown Source) ~[oxygen.jar:?]
at ro.sync.xml.i.d(Unknown Source) ~[oxygen.jar:?]
at ro.sync.xml.i.b(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.m.s.c(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_bb.z(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_r.z(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_s.r(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_s.g(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_s.b(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_r.b(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_db.ab(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_bb.q(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_s.b(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_db.ab(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_bb.q(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_s.b(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_db.ab(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e$_k.b(Unknown Source) ~[oxygen.jar:?]
at ro.sync.ecss.webapp.e.render(Unknown Source) ~[oxygen.jar:?]
at ro.sync.servlet.RESTDocumentManager.buildDocumentInfo(RESTDocumentManager.java:1022) ~[classes/:?]
at ro.sync.servlet.RESTDocumentManager.retrieveDocument(RESTDocumentManager.java:599) ~[classes/:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
-
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: Rendering include content in DocBook
Post by cristi_talau »
Can you try to first read the content of the reference in a String to make sure that the content is fetched correctly?
Here is how I implemented the entity resolver:
Code: Select all
xmlUtilAccess.addPriorityEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
InputSource inputSource = new InputSource(systemId);
inputSource.setCharacterStream(new StringReader(includedFile));
return inputSource;
}
});
Cristian
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
Any thoughts on getCurrentEditorAccess(int).getEditorLocation() exception?
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<chapter xml:id="chapter_1b53cca2-6337-40a0-aeec-409c92f8a2c2" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
<title xml:id="title_e13e7246-70ef-406f-ae0b-a5bd9e1e5430">a002_Chapter</title>
<para>Test chapter</para>
<para/>
<xi:include xpointer="title_0125766b-9997-4275-9eee-8d902abb28ef" href="a3_Section_4ef81e80-6242-4bb2-8aa2-2d417d38417e.xml"/>
</chapter>
Code: Select all
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
if (systemId != null && systemId.startsWith(Config.SCHEME) && systemId.indexOf(Config.HREF) == -1) {
URL[] urls = pluginWorkspaceAccess.getAllEditorLocations(PluginWorkspace.MAIN_EDITING_AREA);
if (urls.length > 0) {
URL baseUrl = urls[0];
URL url = new URL("url for given system id");
// getText(url) returns the content / string form the url
logger.info(systemId + " = " + getText(url));
InputSource inputSource = new InputSource(systemId);
inputSource.setCharacterStream(new StringReader(getText(url)));
return inputSource;
}
}
return null;
}
Code: Select all
https://localhost:25608/a3_Section_4ef81e80-6242-4bb2-8aa2-2d417d38417e.xml = <?xml version="1.0" encoding="utf-8"?><section xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="section_afc810d8-6beb-4757-896f-5637bb155a2b">
<title xml:id="title_0125766b-9997-4275-9eee-8d902abb28ef">a3_Section</title>
<para>Hello, this is a section in A3 section document.</para>
</section>
74265 WARN [ http-nio-8080-exec-10 ] ro.sync.servlet.RESTDocumentManager - Error while loading document: System ID: https://localhost:25608/Editor?ComponentId=229&EditorType=OxygenWeb&Token=authtoken
Severity: warning
Description: An 'include' failed, and no 'fallback' element was found.
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Rendering include content in DocBook
Can you please give us some details about the place were you have added the priority EntityResolver? We are thinking that maybe you placed the code after the document content is resolved.
Best Regards,
Mihaela
http://www.oxygenxml.com
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
Code: Select all
public class MyWorkspaceAccess implements WorkspaceAccessPluginExtension {
private MyRelativeReferenceResolver referenceResolver;
private MyURIResolver uriResolver;
private MyEntityResolver entityResolver;
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
// Resolves actual url into simple filename while inserting it into document
referenceResolver = new MyRelativeReferenceResolver();
pluginWorkspaceAccess.addRelativeReferencesResolver(Config.SCHEME, referenceResolver);
// Handles requests for DITA
uriResolver = new MyURIResolver();
pluginWorkspaceAccess.getXMLUtilAccess().addPriorityURIResolver(uriResolver);
// For DocBook?
entityResolver = new MyEntityResolver(pluginWorkspaceAccess);
pluginWorkspaceAccess.getXMLUtilAccess().addPriorityEntityResolver(entityResolver);
}
public boolean applicationClosing() {
return true;
}
}
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Rendering include content in DocBook
We haven't added support for this API in Web Author doe to some limitations that we hade in the past in our code. Now the limitation is gone so I have added an issue in our internal issue tracker to implement it. We will update this thread when it will be available.manojdcoder wrote: ↑Tue Dec 08, 2020 5:47 am Any thoughts on getCurrentEditorAccess(int).getEditorLocation() exception?
Best Regards,
Mihaela
http://www.oxygenxml.com
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Rendering include content in DocBook
The EntityResolver is registered correctly in your code, on applicationStarted.
We did not managed to reproduce the problem, so we need your help to debug this.
The first step is to check if the reference is resolved if you keep only the EntityResolver (please comment the addition of referenceResolver and uriResolver).
Then, if the reference is still not resolved please try to also to change the code from your resolveEntity method to return an InputSource that provides a simple xml (in other words please try to eliminate the code that retrieves the content of the reference file from your server).
Please let us know if the reference is resolved as expected in this case.
Best Regards,
Mihaela
http://www.oxygenxml.com
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
Code: Select all
InputSource inputSource = new InputSource(systemId);
inputSource.setCharacterStream(new StringReader(
"<?xml version=\"1.0\" encoding=\"utf-8\"?><section xmlns=\"http://docbook.org/ns/docbook\" xmlns:xi=\"http://www.w3.org/2001/XInclude\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"5.0\" xml:id=\"section_afc810d8-6beb-4757-896f-5637bb155a2b\">\r\n"
+ " <title xml:id=\"title_0125766b-9997-4275-9eee-8d902abb28ef\">a3_Section</title>\r\n"
+ " <para>Hello, this is a section in A3 section document.</para>\r\n"
+ "</section>"));
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Rendering include content in DocBook
In 22.1.0.0 version the EntityManager should work. Next thing to try: please include a stacktrace in your resolveEntity implementation and send us the logs to see were it is called from. If you want you can send us the logs on our support email address (support@oxygenxml.com). Thank you.
Best regards,
Mihaela
http://www.oxygenxml.com
-
- Posts: 67
- Joined: Thu Oct 29, 2020 12:01 am
Re: Rendering include content in DocBook
Post by manojdcoder »
Irrespective of that I have emailed you the stack trace. Please let me know if you need any further details.
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service