How to access resources from javascript
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
How to access resources from javascript
Post by steve.cuzner »
I'm writing a javascript function to insert xml fragments which works well with authorAccess.getDocumentController().insertXMLFragment. I would like to store my fragments as resource files outside of the javascript. I've tried the javascript File object, but that doesn't seem to work. How can I read an external file into a javascript string variable that I can then pass to insertXMLFragment?
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: How to access resources from javascript
Post by steve.cuzner »
I've found some success using standard java:
But this only works when I have a absolute path. The above code is in a function in commons.js which is in tmwbook.framework, the same directory as the frag.xml. Ideally, I would put frag.xml in a resources sub-directory of tmwbook.framework, but in any event, I need to find the path to the framework in the javascript. How can I do that?
Code: Select all
fileReader = new java.io.FileReader("T:\\custom\\Oxygen\\frameworks\\tmwbook.framework\\frag.xml");
br = new java.io.BufferedReader(fileReader);
sb = new java.lang.StringBuilder();
line = br.readLine()
while (line != null)
{
sb.append(line);
line = br.readLine();
}
frag = sb.toString();
authorAccess.getWorkspaceAccess().showInformationMessage(frag);
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: How to access resources from javascript
Post by steve.cuzner »
Code: Select all
frameworkDir = authorAccess.getUtilAccess().expandEditorVariables("${frameworkDir}", null);
-
- Posts: 1008
- Joined: Wed Nov 16, 2005 11:11 am
Re: How to access resources from javascript
Post by alex_jitianu »
Hi Steve,
I see you're find the solutions faster that I can answer Yes, this is the way you can obtain the framework directory:
Best regards,
Alex
I see you're find the solutions faster that I can answer Yes, this is the way you can obtain the framework directory:
Code: Select all
frameworkDir = authorAccess.getUtilAccess().expandEditorVariables("${frameworkDir}", null);
Alex
Return to “SDK-API, Frameworks - Document Types”
Jump to
- 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