how to get xmlns attribute of root node in the document
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
-
- Posts: 99
- Joined: Fri Jul 01, 2022 12:08 pm
how to get xmlns attribute of root node in the document
Post by shikhar_472 »
Hi All,
Below are two types of XML which we use with the web Author ,
Xml Type 1:
<n-load xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.application.com/product/document http://applicatiom.subnet/AppInstance/r ... cument.xsd">
.... xml content here
</n-load>
Xml type 2
<xampex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.application.com/product/xampex http://applicatiom.subnet/XampexInstanc ... xampex.xsd">
..... xml content here
</xampex>
In our custom functionality we want to get schemalocation value from the root element. From web author UI, we have seen schema location value of the above xml stored in xmlns attribute.
We are using below code snippet to fetch xmlns attribute that we are getting null value.
authorDocumentModel..getAuthorDocumentController().getAuthorDocumentNode().getNamespace();
Can you please let us know how we can get the xmlns attribute details from the root element.
Thanks.
Below are two types of XML which we use with the web Author ,
Xml Type 1:
<n-load xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.application.com/product/document http://applicatiom.subnet/AppInstance/r ... cument.xsd">
.... xml content here
</n-load>
Xml type 2
<xampex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.application.com/product/xampex http://applicatiom.subnet/XampexInstanc ... xampex.xsd">
..... xml content here
</xampex>
In our custom functionality we want to get schemalocation value from the root element. From web author UI, we have seen schema location value of the above xml stored in xmlns attribute.
We are using below code snippet to fetch xmlns attribute that we are getting null value.
authorDocumentModel..getAuthorDocumentController().getAuthorDocumentNode().getNamespace();
Can you please let us know how we can get the xmlns attribute details from the root element.
Thanks.
-
- Site Admin
- Posts: 172
- Joined: Tue Mar 20, 2018 5:28 pm
Re: how to get xmlns attribute of root node in the document
Post by Bogdan Dumitru »
Hello,
I think you're making a confusion here - you say "we want to get schemalocation value from the root element" but you call "getNamespace" method. The "getNamespace" returns the namespace of the element (the "xmlns" attribute value).
To retrieve the "xsi:schemaLocation" value you have to use ro.sync.ecss.extensions.api.node.AuthorElement.getAttribute(String) method: authorDocumentModel.getAuthorDocumentController().getAuthorDocumentNode().getRootElement().getAttribute("xsi:schemaLocation")
If you need the namespace of the root element you have to use "authorDocumentModel.getAuthorDocumentController().getAuthorDocumentNode().getRootElement().getNamespace()" instead of "authorDocumentModel.getAuthorDocumentController().getAuthorDocumentNode().getNamespace()".
I think you're making a confusion here - you say "we want to get schemalocation value from the root element" but you call "getNamespace" method. The "getNamespace" returns the namespace of the element (the "xmlns" attribute value).
To retrieve the "xsi:schemaLocation" value you have to use ro.sync.ecss.extensions.api.node.AuthorElement.getAttribute(String) method: authorDocumentModel.getAuthorDocumentController().getAuthorDocumentNode().getRootElement().getAttribute("xsi:schemaLocation")
If you need the namespace of the root element you have to use "authorDocumentModel.getAuthorDocumentController().getAuthorDocumentNode().getRootElement().getNamespace()" instead of "authorDocumentModel.getAuthorDocumentController().getAuthorDocumentNode().getNamespace()".
Bogdan Dumitru
http://www.oxygenxml.com
http://www.oxygenxml.com
-
- Site Admin
- Posts: 172
- Joined: Tue Mar 20, 2018 5:28 pm
Re: how to get xmlns attribute of root node in the document
Post by Bogdan Dumitru »
Related thread: how cache a schema file in web author.
Bogdan Dumitru
http://www.oxygenxml.com
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