Bonjour à tous,
Je n'arrive pas à créer un fichier XML avec l'espace de nom "http://www.domain.tld/ns/font".
Je m'attendais à ce que la méthode createElementNS "écrivait" l'espace de nom !Code:
1
2
3
4
5
6
7
8
9
10
11
12 String fontNS = "http://www.domain.tld/ns/font"; OS2WindowsMetricsTable oS2WindowsMetricsTable = ttfFont.getOS2Windows(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); OS2WindowsMetricsDom = db.newDocument(); final Element rootElement = OS2WindowsMetricsDom.createElementNS(fontNS, "font:oS2WindowsMetrics"); OS2WindowsMetricsDom.appendChild(rootElement); ...
Pour le moment, j'obtient :
Alors que le but est d'obtenir le code suivant :Code:
1
2
3
4
5 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <font:oS2WindowsMetrics> <font:version>3</font:version> ... </font:oS2WindowsMetrics>
Merci de votre aide. :ccool:Code:
1
2
3
4
5 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <font:oS2WindowsMetrics xmlns:font="http://www.domain.tld/ns/font"> <font:version>3</font:version> ... </font:oS2WindowsMetrics>