AuthorSchemaManager for validating AuthorDocumentFragments
Oxygen general issues.
-
- Posts: 206
- Joined: Thu Dec 01, 2011 4:22 pm
- Location: Hamburg, Germany
AuthorSchemaManager for validating AuthorDocumentFragments
Hello,
I want to check, if a certain XML String can be inserted at a certain location.
To insert a XML String schema aware you can easily use ro.sync.ecss.extensions.api.AuthorDocumentController.insertXMLFragmentSchemaAware(String, int);
But how can I just check if a certain XML String may be inserted according to schema rules?
I tried to use the ro.sync.ecss.extensions.api.AuthorSchemaManager.canInsertDocumentFragment(AuthorDocumentFragment, int, short)
method, but I cannot figure out how to create an ro.sync.ecss.extensions.api.node.AuthorDocumentFragment from a XML String.
When I use the ro.sync.ecss.extensions.api.AuthorDocumentController.createNewDocumentTextFragment(String) method to create an AuthorDocumentFragment the canInsertDocumentFragment always returns true, even thought if the element actually is not allowed.
Can you please give me a hint how I can check if a certain xml string is allowed at a certain offset?
With xml String I mean something like this : <image href="test.jpg" />
Best regards,
Simon
I want to check, if a certain XML String can be inserted at a certain location.
To insert a XML String schema aware you can easily use ro.sync.ecss.extensions.api.AuthorDocumentController.insertXMLFragmentSchemaAware(String, int);
But how can I just check if a certain XML String may be inserted according to schema rules?
I tried to use the ro.sync.ecss.extensions.api.AuthorSchemaManager.canInsertDocumentFragment(AuthorDocumentFragment, int, short)
method, but I cannot figure out how to create an ro.sync.ecss.extensions.api.node.AuthorDocumentFragment from a XML String.
When I use the ro.sync.ecss.extensions.api.AuthorDocumentController.createNewDocumentTextFragment(String) method to create an AuthorDocumentFragment the canInsertDocumentFragment always returns true, even thought if the element actually is not allowed.
Can you please give me a hint how I can check if a certain xml string is allowed at a certain offset?
With xml String I mean something like this : <image href="test.jpg" />
Best regards,
Simon
Simon Scholz
vogella GmbH
http://www.vogella.com
vogella GmbH
http://www.vogella.com
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: AuthorSchemaManager for validating AuthorDocumentFragments
Post by alex_jitianu »
Hi Simon,
The ro.sync.ecss.extensions.api.AuthorDocumentController.createNewDocumentTextFragment(String) method creates a text fragment, even if the string you provide represents an XMl content.
What you can do is to use the following method that creates an AuthorDocumentFragment representing an XML content:
Then you can check if this document fragment can be inserted at a specific offset by using the method you already discovered: ro.sync.ecss.extensions.api.AuthorSchemaManager.canInsertDocumentFragment(AuthorDocumentFragment, int, short)
Please let us know if you need further assistance.
Best regards,
Alex
The ro.sync.ecss.extensions.api.AuthorDocumentController.createNewDocumentTextFragment(String) method creates a text fragment, even if the string you provide represents an XMl content.
What you can do is to use the following method that creates an AuthorDocumentFragment representing an XML content:
Code: Select all
/**
* Create a new {@link AuthorDocumentFragment} from an XML string in a specified context.
* <br/>
* The author content contains the entire XML document text and special marker characters.
* Each author node points in the content to the start and end marker characters which are used to
* delimit it's range.
* The start and end offsets pointed to by the AuthorNode can be retrieved using the
* AuthorNode.getStartOffset() and AuthorNode.getEndOffset()
*
* @param xmlFragment The XML Fragment.
* @param contentOffset The offset where the XML fragment should be inserted.
* @return The newly created {@link AuthorDocumentFragment}.
* It does not return a <code>null</code> fragment.
* @throws AuthorOperationException If the new fragment creation fails.
*/
AuthorDocumentFragment createNewDocumentFragmentInContext(String xmlFragment, int contentOffset)
throws AuthorOperationException;
Please let us know if you need further assistance.
Best regards,
Alex
-
- Posts: 206
- Joined: Thu Dec 01, 2011 4:22 pm
- Location: Hamburg, Germany
Re: AuthorSchemaManager for validating AuthorDocumentFragments
Hello Alex,
The name createNewDocumentFragmentInContext and having a parameter, which specifies the offset(@param contentOffset The offset where the XML fragment should be inserted.) leaded me to the conclusion that this method would directly insert the xml fragment into the document, which was not desired at that point.
But with the createNewDocumentFragmentInContext everything works fine.
Thanks for the hint.
Maybe you could mention in your JavaDoc that the resulting AuthorDocumentFragment is not directly inserted to the document and that the insertFragmentSchemaAware method does it.
Best regards,
Simon
The name createNewDocumentFragmentInContext and having a parameter, which specifies the offset(@param contentOffset The offset where the XML fragment should be inserted.) leaded me to the conclusion that this method would directly insert the xml fragment into the document, which was not desired at that point.
But with the createNewDocumentFragmentInContext everything works fine.
Thanks for the hint.
Maybe you could mention in your JavaDoc that the resulting AuthorDocumentFragment is not directly inserted to the document and that the insertFragmentSchemaAware method does it.
Best regards,
Simon
Simon Scholz
vogella GmbH
http://www.vogella.com
vogella GmbH
http://www.vogella.com
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: AuthorSchemaManager for validating AuthorDocumentFragments
Post by alex_jitianu »
Hi Simon,
This is a good opportunity to review a little our documentation. I've already added an issue to correct the JavaDoc as well as providing more information about the two methods. Method createNewDocumentTextFragment's documentation is also extremely vague.
Best regards,
Alex
This is a good opportunity to review a little our documentation. I've already added an issue to correct the JavaDoc as well as providing more information about the two methods. Method createNewDocumentTextFragment's documentation is also extremely vague.
Best regards,
Alex
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