2015-07-19 21 views
0

語境:如何在一個xwiki頁面中插入一個包含鏈接的svg?

我有一個包含鏈接到外部頁面的SVG圖形。如果我直接在Firefox或IE鏈接中打開它,請轉到其他URL。

我要插入的圖形在XWiki實現頁面。瑣碎的方式:在wisiwig編輯Image/Attached image...在XWiki實現2.1源代碼,但產生[[image:foo.svg||height="..." width="..."]] ...鏈接不再點擊。

問:

我怎樣才能插入在SVG的方式鏈接SVG文檔仍然活躍?

小例子:

<svg xmlns="http://www.w3.org/2000/svg" 
 
     xmlns:xlink="http://www.w3.org/1999/xlink"> 
 
    <rect x="0" y="0" height="130" width="120" 
 
      style="stroke:#000000; fill: #ffffff"/> 
 
    <rect x="10" y="10" height="50" width="100" 
 
      style="stroke:#ff0000; fill: #0000ff"/> 
 
    <a xlink:href="http://www.google.fr"> 
 
\t <rect x="10" y="70" height="50" width="100" 
 
\t  style="stroke:#ff0000; fill: #00ff00"/> 
 
    </a> 
 
</svg>

正如你可以看到綠色的矩形底部處包含一個鏈接到谷歌。但是當我將它插入到一個xwiki頁面時,鏈接不活動。我查看了生成的HTML,並看到svg包含在<img>標記中,我認爲這是鏈接未處於活動狀態的原因。但是,我怎麼也找不到,使其工作

參考文獻:

我使用的是6.4.4版本XWiki實現和2.1 XWiki實現語法,但我會接受7版本XWiki實現頁面的溶液或另一種語法

回答

0

的問題是不與XWiki實現,但與方式瀏覽器處理SVGs爲<img>標籤的目標。你可以嘗試一個簡單的HTML:

<html> 
    <body> 
    <image src="foo.svg"/> 
    </body> 
</html> 

這不會是可點擊的。

您可以嵌入而不是SVG:

<html> 
    <body> 
    <svg xmlns="http://www.w3.org/2000/svg" 
     xmlns:xlink="http://www.w3.org/1999/xlink"> 
     <rect x="0" y="0" height="130" width="120" 
      style="stroke:#000000; fill: #ffffff"/> 
     <rect x="10" y="10" height="50" width="100" 
      style="stroke:#ff0000; fill: #0000ff"/> 
     <a xlink:href="http://www.google.fr"> 
     <rect x="10" y="70" height="50" width="100" 
       style="stroke:#ff0000; fill: #00ff00"/> 
     </a> 
    </svg> 
    </body> 
</html> 

如果你可以在wiki文檔中複製SVG文件的內容,那麼你可以只使用一個{{html clean="false"}}包裝周圍:

Some **wiki content** 

{{html clean="false"}} 
<svg ....> 
</svg> 
{{/html}} 

Some __other wiki content__. 

如果不是,那麼你應該這樣做:

Some **wiki content** 

{{velocity}} 
{{html clean="false"}} 
$doc.getAttachment('foo.svg').getContentAsString('UTF-8') 
{{/html}} 
{{/velocity}} 

Some __other wiki content__. 
+1

感謝您的詳細解答。但是,在HTML中直接包含「」集羣並不適用於IE。幸運的是,它很容易使用''標籤:'{{速度}} {{HTML}} <對象數據= 「$ doc.getAttachmentURL( 'foo.svg')」 類型= 「圖像/ SVG + xml」 的width =「120」height =「320」/> {{/ html}} {{/ velocity}}'。這一款適用於Firefox,Chrome和IE –

相關問題