我想在xml中使用这种格式
# inside a docker-compose file
...
volumes:
bind-test:
driver: local
driver_opts:
type: none
o: bind
device: /home/user/test
or:
version: '3'
services:
myservice:
volumes:
- ./path:/volume/path
我正在使用以下代码。
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:001.003.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tech:xsd:pain.001.001.03">
<staff id="1">
<firstname>yong</firstname>
</staff>
</Document>
我得到的输出是:
Namespace namespace = Namespace.getNamespace("urn:001.003.03");
Namespace namespace1 = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Namespace namespace2 = Namespace.getNamespace("schemaLocation", "urn:tech:xsd:pain.001.001.03");
Element document = new Element("Document", namespace);
Document doc = new Document(document);
doc.setRootElement(document);
document.addNamespaceDeclaration(namespace1);
document.addNamespaceDeclaration(namespace2);
Element staff = new Element("staff", namespace);
staff.setAttribute(new Attribute("id", "1"));
staff.addContent(new Element("firstname",namespace).setText("yong"));
doc.getRootElement().addContent(staff);
我需要像 xsi:schemaLocation 这样的名称空间,但它需要生成像 xmlns:schemaLocation