xi:include is not included while evaluating XPath.
Oxygen general issues.
-
- Posts: 10
- Joined: Fri Oct 02, 2009 12:24 am
xi:include is not included while evaluating XPath.
Post by mveerasamy »
I am having problem in evaluating XPath while using xi:include.
My Xml will look like this:
Where S123.xml contains the following:
Now my question is when I use the following code I got only the Child1 and Child2.
What should I have to do to get all child(Child1-4) elements?
[Note: But Oxygen’s xpath builder provides all 4 child elements when I search with the same Xpath. Is your UI using different API?]
My Xml will look like this:
Code: Select all
<test>
<child>Child1 </child>
<child>Child2 </child>
<xi:include href=”S123.xml”/>
</test>
Code: Select all
<child>Child3 </child>
<child>Child4 </child>
Code: Select all
String xPath=” //child”;
authorAccess.getDocumentController().evaluateXPath(xPath, false, false, false);
authorAccess.getDocumentController().findNodesByXPath(xPath, false, false, false);
[Note: But Oxygen’s xpath builder provides all 4 child elements when I search with the same Xpath. Is your UI using different API?]
-
- Posts: 9436
- Joined: Fri Jul 09, 2004 5:18 pm
Re: xi:include is not included while evaluating XPath.
Hi,
We use Saxon 9 and XPath 2.0 to run XPath's from the Author API but the XPaths are only performed on the current document's content.
You can easily create a method to iterate all nodes (which also goes into the referenced content) and find all sect1's like:
Regards,
Radu
We use Saxon 9 and XPath 2.0 to run XPath's from the Author API but the XPaths are only performed on the current document's content.
You can easily create a method to iterate all nodes (which also goes into the referenced content) and find all sect1's like:
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 {
List<AuthorNode> allSect1s = new ArrayList<AuthorNode>();
findSect1s(authorAccess.getDocumentController().getAuthorDocumentNode().getRootElement(), allSect1s);
}
private void findSect1s(AuthorNode node, List<AuthorNode> allSect1s) {
if("sect1".equals(node.getName())) {
allSect1s.add(node);
} else if(node instanceof AuthorParentNode) {
List<AuthorNode> contentNodes = ((AuthorParentNode)node).getContentNodes();
for (int i = 0; i < contentNodes.size(); i++) {
findSect1s(contentNodes.get(i), allSect1s);
}
}
}
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 10
- Joined: Fri Oct 02, 2009 12:24 am
Re: xi:include is not included while evaluating XPath.
Post by mveerasamy »
Thanks for the reply.
Also i am having one more problem. I am trying to set my custom Name Space to my root node. there is method getNamespace() availavle in AuthorNode. but there is no setNamespace() there. is there any setNamespace() available anywhere?.
Thanks in advance,
Muthu
Also i am having one more problem. I am trying to set my custom Name Space to my root node. there is method getNamespace() availavle in AuthorNode. but there is no setNamespace() there. is there any setNamespace() available anywhere?.
Thanks in advance,
Muthu
-
- Posts: 9436
- Joined: Fri Jul 09, 2004 5:18 pm
Re: xi:include is not included while evaluating XPath.
Hi Muthu,
The code should be something like:
Regards,
Radu
The code should be something like:
Code: Select all
AuthorElement root = authorAccess.getDocumentController().getAuthorDocumentNode().getRootElement();
String searchPrefix = "";
if(root.getName().indexOf(":") != -1) {
searchPrefix = ":" + root.getName().substring(0, root.getName().indexOf(":"));
}
int rootAttrs = root.getAttributesCount();
for (int i = 0; i < rootAttrs; i++) {
String attr = root.getAttributeAtIndex(i);
//Search for the xmlns declaration on the element
if(attr.startsWith("xmlns" + searchPrefix)) {
//Found the attribute which maps to the root namespace
authorAccess.getDocumentController().setAttribute(attr, new AttrValue("NEW_NAMESPACE_VALUE"), root);
break;
}
}
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