Netbeans Platform access DTD from other module
-
28-04-2021 - |
سؤال
We're writing a Netbeans platform app, and we want to add some data as an XML files. Also we want to have a DTD for that files, and we want to put it in one of our main modules, as it should be used in different places and dependent XML files will be in a different modules. Now how can I point to that DTD from XMLs in another modules?
I'll be very thankful for any advice.
Also maybe mentioned above idea is bad but that's all I could think about, so critique is welcomed.
المحلول
Say you have a module file structure like this
MyModule
com.mydomain.mypackage
layer.xml
main.dtd
And layer.xml
contains
<filesystem>
<folder name="MyDTDs">
<file name="myMainDTD" url="main.dtd"/>
</folder>
</filesystem>
Then you can get a FileObject
to the dtd file from another module by doing
FileObject root = FileUtil.getConfigRoot();
FileObject myDTDs = root.getFileObject("MyDTDs");
if (myDTDs != null) {
FileObject mainDTD = myDTDs.getFileObject("myMainDTD");
}
And from the FileObject
you can get an InputStream
and so forth.
لا تنتمي إلى StackOverflow