x:include resolved xml document
Oxygen general issues.
-
- Posts: 27
- Joined: Tue Nov 17, 2009 10:16 pm
x:include resolved xml document
Post by guna@ebscohost.com »
Hi,
I have a xml document, which has 10 x:includes.
I need an xml document String, will all x:include resolved with corresponding content.
I am wondering , it there a method in api to give this value.
example
sorcDoc.xml
<test>
<x:include href="S31.xml"/>
</text>
S31.xml
<hello>
how are you
</hello>
output i needed as xml String is
<test>
<hello>
how are you
</hello>
</test>
can you guide me, how to get this value?
Thanks
Guna
I have a xml document, which has 10 x:includes.
I need an xml document String, will all x:include resolved with corresponding content.
I am wondering , it there a method in api to give this value.
example
sorcDoc.xml
<test>
<x:include href="S31.xml"/>
</text>
S31.xml
<hello>
how are you
</hello>
output i needed as xml String is
<test>
<hello>
how are you
</hello>
</test>
can you guide me, how to get this value?
Thanks
Guna
Re: x:include resolved xml document
Hi Guna,
You have API to get the XML content as a string from a document fragment but if the fragment contains xi:includes they are not expanded.
For each xi:include node you have to create a document fragment and serialize that one.
Here is some sample code which might give you an idea where to begin:
Regards,
Radu
You have API to get the XML content as a string from a document fragment but if the fragment contains xi:includes they are not expanded.
For each xi:include node you have to create a document fragment and serialize that one.
Here is some sample code which might give you an idea where to begin:
Code: Select all
/**
* @see ro.sync.ecss.extensions.api.AuthorOperation#doOperation(ro.sync.ecss.extensions.api.AuthorAccess, ro.sync.ecss.extensions.api.ArgumentsMap)
*/
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args)
throws IllegalArgumentException, AuthorOperationException {
try {
AuthorDocumentFragment df = authorAccess.getDocumentController().createDocumentFragment(authorAccess.getDocumentController().getAuthorDocumentNode().getRootElement(), true);
String xmlFragWithXIIncludesNotExpanded = authorAccess.getDocumentController().serializeFragmentToXML(df);
List<String> xiIncludeContents = new ArrayList<String>();
findXIIncludes(authorAccess, xiIncludeContents, authorAccess.getDocumentController().getAuthorDocumentNode().getRootElement());
//Now you can merge the XIInclude contents back into the original content.
} catch (BadLocationException e) {
e.printStackTrace();
}
}
private void findXIIncludes(AuthorAccess authorAccess, List<String> xiIncludesContent, AuthorNode elem) throws BadLocationException {
if(elem.getName().equals("xi:include")) {
//Found xi:include.
AuthorDocumentFragment df = authorAccess.getDocumentController().createDocumentFragment(elem.getStartOffset() + 2, elem.getEndOffset() - 2);
xiIncludesContent.add(authorAccess.getDocumentController().serializeFragmentToXML(df));
} else if(elem instanceof AuthorParentNode){
List<AuthorNode> children = ((AuthorParentNode)elem).getContentNodes();
for (int i = 0; i < children.size(); i++) {
findXIIncludes(authorAccess, xiIncludesContent, children.get(i));
}
}
}
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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