2012-09-06 17 views
0

我想知道在XSLT期間如何以及爲什麼Saxon在XSL元素之間使用空格。以下是可能受上述行爲影響的示例:在XSLT期間,Saxon在屬性中使用了空白嗎?

在XSLT期間,如何以及爲什麼Saxon在XSL元素之間使用空格?

<div style="display:none;"> 
    <xsl:choose> 
     <xsl:when test="true"> 
     <xsl:attribute name="id"> 
      <xsl:choose> 
       <xsl:when> 
       etc ec 
       </xsl:when> 
       <xsl:otherwise></xsl:otherwise> 
      </xsl:choose> 
      </xsl:attribute> 
     </xsl:when> 
     <xsl:otherwise></xsl:otherwise> 

</div> 

爲什麼<div<xsl:choose>之間的空白可能會導致以下錯誤:含什麼,但空格(像在您的示例)

XSLT attribute node (id) cannot be created after the children of the containing element 
+0

您錯過了第一個「」的結束標記' –

回答

1

文本節點沒有影響(它們在解析的非常早期階段被刪除),除非在樣式表的某個父元素中碰巧具有屬性xml:space =「preserve」。 (在樣式表中放置xml:space =「preserve」幾乎總是壞消息,因爲這樣的原因,但人們經常這樣做,並且可能在這裏解決問題。)

另一種可能性(I在12年中只看到過一次......),看起來像空白的東西不是。例如,它可能包含一個非破壞性空間或一個零寬度空間,它看起來是白色的,但不是正式的空白。