2011-01-06 8 views
2

Batikが2つのsvg-documentをロードして別のフォームに別の 文書を追加しましたが、id属性が保存された文書の中でいくつかの属性に現れました( )。保存された文書をInkscapeで開こうとすると、そのファイルを開くことができなかったというエラーが表示されます。 いくつかのIDを手動で削除することで、ファイルをInkscapeで開くことができます。batik-id-attributeが保存された文書で2回発生しました

ありがとうございました。文書の

...

try { 
// Load the basic symbol 
String parser = XMLResourceDescriptor.getXMLParserClassName(); 
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); 
Document documentBasicSymbol = f.createSVGDocument(imgFileBasicSymbol.toURI().toString()); 


// Set the fill color of the basic symbol to symbolColor 
Element element = documentBasicSymbol.getElementById("basic_symbol"); 
setSymbolFillColor(element, symbolColor); 


// Load the supplementary symbol 
Document documentSupplemtarySymbol =  
f.createDocument(imgFileSupplementarySymbol.toURI().toString()); 

// Add it to the basic symbol: 
Node nodeSupplementarySymbol = documentBasicSymbol.importNode(documentSupplemtarySymbol.getElementById("supplementary_symbol"), true); 
     documentBasicSymbol.getDocumentElement().appendChild(nodeSupplementarySymbol); 

storeDocument(documentBasicSymbol, "SuppElementZuBasic.svg"); 

...

一部:

xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:svg="http://www.w3.org/2000/svg" zoomAndPan="magnify" 
contentStyleType="text/css" id="svg2" height="100" 
preserveAspectRatio="xMidYMid meet" 
xmlns="http://www.w3.org/2000/svg" id="svg2" version="1.2"> 
    <g id="layer1" id="layer1" 
    transform="translate(1.4982643,1.4982643)"> 
    <rect x="64.599998" y="29.674999" width="67.803474" 
    style="fill:blue;stroke:#000000;stroke-width:2.0965271;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" 
    height="37.653473" id="basic_symbol" id="basic_symbol" /> 
    </g> 
    <path d="m 116.10938,37.703125 0,10.8125 -47.531255,0 0,2.40625 47.531255,0 0,4.5 0,0.59375 0.90625,0.28125 13.49999,6 0.3125,-0.875 0.59375,-0.90625 -13.21874,-5.75 0,-17.0625 -2.09375,0 z" 
    id="supplementary_symbol" 
    style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" 
    id="supplementary_symbol" /> 

答えて

1

あなたがidを使用する必要がない場合は、あなたが3 argument importNodeを試してみてください第3の値(trimIds)はtrueに設定されます。

他にも、私が考えることができるのは、追加の要素のDOMを歩いてIDを調整/削除することだけです。

おそらくbug against Batikを提出している可能性があります。それは本当にあなたが違法なXMLを生成させるべきではありません。

関連する問題