Content completion issue
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 168
- Joined: Fri Jan 20, 2017 1:11 pm
Content completion issue
Hello,
We used the version 25.0.0.0 of oxygen sdk.
We have this xsd :
In content completion, we have this :
If I insert model element alone, the model attribute is well defined with TBD value.
If I insert version element in an existing model element, the version attribute is well defined with TBD value.
But if I force the insertion of version element without the model parent existing, the schemaAware insertion will add something like this :
And if I force the insertion of versrank element without the version and model parent existing, the schemaAware insertion will add something like this :
Why content completion rules are lost when insertion is build thanks to shemaAware ?
I tried to set those attributes manually thanks to AuthorDocumentFilter, but it does not work.
The method insertNode is used to insert parents node (model and/or version), before the insertion I set the attribute values.
It seems to insert node correctly with good values, but when it comes to insertFragment method, attributes values have been replaced.
How can I fix this ?
Regards,
Isabelle
We used the version 25.0.0.0 of oxygen sdk.
We have this xsd :
Code: Select all
<xs:attribute name="model" type="xs:string"/>
<xs:element name="model" type="modelType"/>
<xs:complexType name="modelType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="version"/>
<xs:element minOccurs="0" ref="batchno"/>
<xs:element minOccurs="0" ref="maintlevel"/>
</xs:sequence>
<xs:attribute ref="model" use="required"/>
</xs:complexType>
<xs:attribute name="version" type="xs:string"/>
<xs:element name="version" type="versionType"/>
<xs:complexType name="versionType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="versrank"/>
</xs:sequence>
<xs:attribute ref="version" use="required"/>
<xs:attribute ref="id"/>
</xs:complexType>
<xs:element name="versrank" type="versrankType"/>
<xs:complexType name="versrankType">
<xs:choice maxOccurs="unbounded">
<xs:element ref="single"/>
<xs:element ref="range"/>
</xs:choice>
<xs:attribute ref="verstatus"/>
</xs:complexType>
<xs:element name="single" type="xs:string"/>
<xs:element name="range" type="xs:string"/>
Code: Select all
<elementProposals path="model">
<insertAttribute name="model" value="TBD"/>
</elementProposals>
<elementProposals path="version">
<insertAttribute name="version" value="TBD"/>
</elementProposals>
Code: Select all
<model model="TBD"/>
Code: Select all
<model model="TBD">
<version version="TBD"/>
</model>
Code: Select all
<model model="model_gwf_gfs_2yb">
<version version="TBD"/>
</model>
Code: Select all
<model model="model_xpm_hfs_2yb">
<version version="version_jqm_hfs_2yb">
<versrank/>
</version>
</model>
I tried to set those attributes manually thanks to AuthorDocumentFilter, but it does not work.
The method insertNode is used to insert parents node (model and/or version), before the insertion I set the attribute values.
Code: Select all
@Override
public boolean insertNode(AuthorDocumentFilterBypass authorDocumentFilterBypass, int i, AuthorNode authorNode)
{
setRequiredAttributes(authorNode);
return super.insertNode(authorDocumentFilterBypass, i, authorNode);
}
private void setRequiredAttributes(AuthorNode authorNode) {
AuthorElement elementNote = (AuthorElement) authorNode;
if(StringUtils.equals(authorNode.getName(), "model")){
elementNote.setAttribute("model", new AttrValue("TBD"));
} else if(StringUtils.equals(authorNode.getName(), "version")){
elementNote.setAttribute("version", new AttrValue("TBD"));
}
}
How can I fix this ?
Regards,
Isabelle
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Content completion issue
Hi Isabelle,
Could you prepare for me a full valid sample project containing a valid XML Schema, valid XML sample document and cc_config.xml file with which I can reproduce the problem on my side? I could try to start an investigation into this. I think I have a hunch were the problem is.
About your planned workaround, indeed looking at our code the "insertNode" callback from the documentFilter is used to create ancestor elements when someone wants to insert an element which would be invalid at caret position. But after we insert the element in the document we make changes to it later in our code and add the attributes to it. So in your case maybe this callback "AuthorDocumentFilter.setAttribute(AuthorDocumentFilterBypass, String, AttrValue, AuthorElement)" would be more interesting to intercept.
Regards,
Radu
Could you prepare for me a full valid sample project containing a valid XML Schema, valid XML sample document and cc_config.xml file with which I can reproduce the problem on my side? I could try to start an investigation into this. I think I have a hunch were the problem is.
About your planned workaround, indeed looking at our code the "insertNode" callback from the documentFilter is used to create ancestor elements when someone wants to insert an element which would be invalid at caret position. But after we insert the element in the document we make changes to it later in our code and add the attributes to it. So in your case maybe this callback "AuthorDocumentFilter.setAttribute(AuthorDocumentFilterBypass, String, AttrValue, AuthorElement)" would be more interesting to intercept.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 5
- Joined: Sat Apr 29, 2023 8:05 am
Re: Content completion issue
Based on the information provided, it seems like the issue is related to the behavior of the "insertFragment" method in the context of schema-aware content completion. When you insert a fragment using "insertFragment," it may override the attribute values that you have set manually before the insertion.
To address this issue, you can try the following approach:
Note: Make sure you register your custom AuthorNodeInsertFragmentHandler appropriately in your Oxygen XML plugin to ensure that it is used for content completion.AI directory
By using the above approach, you should be able to ensure that the "model" and "version" attributes are correctly set even when inserting elements through schema-aware content completion.
To address this issue, you can try the following approach:
- Override the "insertFragment" method:
Instead of setting the attributes directly on the node before insertion, you can override the "insertFragment" method in your custom AuthorNodeInsertFragmentHandler. This way, you can intercept the insertion and modify the attributes of the inserted nodes before they are added to the document. - Set the required attributes during "insertFragment":
Inside your overridden "insertFragment" method, you can traverse the inserted fragment nodes, find the elements where you want to set the "model" and "version" attributes, and then update their attribute values accordingly.
Code: Select all
public class CustomInsertFragmentHandler extends AuthorNodeInsertFragmentHandler {
@Override
protected void insertFragment(AuthorNode targetNode, AuthorDocumentFragment fragmentToInsert, boolean cloneIfNeeded, AuthorAccess authorAccess) throws AuthorOperationException {
super.insertFragment(targetNode, fragmentToInsert, cloneIfNeeded, authorAccess);
// Find the model and version elements and set their required attributes
if (targetNode instanceof AuthorElement) {
AuthorElement insertedElement = (AuthorElement) targetNode;
if (insertedElement.getName().equals("model")) {
// Set 'model' attribute to 'TBD' if it doesn't exist
if (insertedElement.getAttribute("model") == null) {
insertedElement.setAttribute("model", new AttrValue("TBD"));
}
} else if (insertedElement.getName().equals("version")) {
// Set 'version' attribute to 'TBD' if it doesn't exist
if (insertedElement.getAttribute("version") == null) {
insertedElement.setAttribute("version", new AttrValue("TBD"));
}
}
}
}
}
Note: Make sure you register your custom AuthorNodeInsertFragmentHandler appropriately in your Oxygen XML plugin to ensure that it is used for content completion.AI directory
By using the above approach, you should be able to ensure that the "model" and "version" attributes are correctly set even when inserting elements through schema-aware content completion.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Content completion issue
Hi John,
I do not think your advice applies in this particular case.
Oxygen has an insertion strategy which automatically creates ancestor elements when the end user attempts to insert an element which is invalid at the caret position.
And this insertion strategy uses the "insertNode" API to create the ancestor elements, but after calling the "insertNode" it also sets some attributes on the inserted elements and this generates the problem reported by Isabelle.
Regards,
Radu
I do not think your advice applies in this particular case.
Oxygen has an insertion strategy which automatically creates ancestor elements when the end user attempts to insert an element which is invalid at the caret position.
And this insertion strategy uses the "insertNode" API to create the ancestor elements, but after calling the "insertNode" it also sets some attributes on the inserted elements and this generates the problem reported by Isabelle.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Content completion issue
Hi isabelle,
We have a tech support form to which you can attach a zip file:
https://www.oxygenxml.com/techSupport.html
Or you can email us (support@oxygenxml.com).
Regards,
Radu
We have a tech support form to which you can attach a zip file:
https://www.oxygenxml.com/techSupport.html
Or you can email us (support@oxygenxml.com).
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 168
- Joined: Fri Jan 20, 2017 1:11 pm
Re: Content completion issue
Radu,
I used the tech support form to send you a zip files with the 3 files requested.
In order to reproduce the issue, try to insert version or versrank element thanks to content completion, directly in applic element.
Regards,
Isabelle
I used the tech support form to send you a zip files with the 3 files requested.
In order to reproduce the issue, try to insert version or versrank element thanks to content completion, directly in applic element.
Regards,
Isabelle
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Content completion issue
Hi,
Based on the received samples I confirm that our next Oxygen version 26 release (October 2023) should have a fix for this reported problem.
Regards,
Radu
Based on the received samples I confirm that our next Oxygen version 26 release (October 2023) should have a fix for this reported problem.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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