Netbeans Platform从其他模块访问DTD

时间:2023-01-27 23:00:45

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?

我们正在编写一个Netbeans平台应用程序,我们希望将一些数据添加为XML文件。此外,我们希望为这些文件提供DTD,并且我们希望将其放在我们的一个主要模块中,因为它应该在不同的地方使用,并且相关的XML文件将在不同的模块中。现在我如何从另一个模块中的XML指向DTD?

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.

也许上面提到的想法很糟糕,但这是我能想到的,所以批评是受欢迎的。

1 个解决方案

#1


1  

Say you have a module file structure like this

假设您有这样的模块文件结构

MyModule
  com.mydomain.mypackage
    layer.xml
    main.dtd

And layer.xml contains

并且layer.xml包含

<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

然后,您可以通过执行从另一个模块获取文件对象到dtd文件

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.

从FileObject中,您可以获得InputStream等等。

#1


1  

Say you have a module file structure like this

假设您有这样的模块文件结构

MyModule
  com.mydomain.mypackage
    layer.xml
    main.dtd

And layer.xml contains

并且layer.xml包含

<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

然后,您可以通过执行从另一个模块获取文件对象到dtd文件

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.

从FileObject中,您可以获得InputStream等等。