2017-06-12 14 views
0

をorg.w3c使用して、複数の値を持つのschemaLocation:XSI:私はschemaLocation属性に複数の値を追加しようとしています

Document document = null; 
     Element documentElement = null; 
     final DocumentBuilderFactory factory = DocumentBuilderFactory 
      .newInstance(); 
     Element root = null; 
     try { 
      final DocumentBuilder builder = factory.newDocumentBuilder(); 
      document = builder.newDocument(); 

      root = document.createElement("kml"); 
      document.appendChild(root); 
      documentElement = document.createElement("Document"); 
      final Element topNameElement = document.createElement("name"); 
      documentElement.appendChild(topNameElement); 
      root.appendChild(documentElement); 

      root.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xsi", 
       "http://www.w3.org/2001/XMLSchema-instance"); 
      root.setAttribute("xmlns", "http://schemas.opengis.net/kml/2.2.0"); 
      root.setAttribute("xmlns:ar", "http://schemas.opengis.net/arml/2.0"); 
      root.setAttribute("xsi:schemaLocation", "http://schemas.opengis.net/kml/2.2.0 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd http://schemas.opengis.net/arml/2.0  http://schemas.opengis.net/arml/2.0/arml.xsd"); 

しかし、結果は以下のとおりです。

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://schemas.opengis.net/kml/2.2.0" xmlns:ar="http://schemas.opengis.net/arml/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.opengis.net/kml/2.2.0 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd &#9;http://schemas.opengis.net/arml/2.0 &#9;http://schemas.opengis.net/arml/2.0/arml.xsd"> 
<kml> 

</kml> 

がどのように私は複数の値を追加しました エンコーディングを削除しますか?

答えて

1

空白文字です。あなたのコードでは、schemaLocationエントリの間に追加の空白を使用しています。毎回1つのスペースに減らしてみてください。

関連する問題