2012-01-26 27 views

Trả lời

13

Các bắt chước sau XSLT 2.0 xây dựng:

Tạo mẫu trong một chế độ mà sẽ tái xây dựng các nút của bạn mà không gian tên:

<!-- generate a new element in the same namespace as the matched element, 
    copying its attributes, but without copying its unused namespace nodes, 
    then continue processing content in the "copy-no-namepaces" mode --> 

<xsl:template match="*" mode="copy-no-namespaces"> 
    <xsl:element name="{local-name()}" namespace="{namespace-uri()}"> 
     <xsl:copy-of select="@*"/> 
     <xsl:apply-templates select="node()" mode="copy-no-namespaces"/> 
    </xsl:element> 
</xsl:template> 

<xsl:template match="comment()| processing-instruction()" mode="copy-no-namespaces"> 
    <xsl:copy/> 
</xsl:template> 

Áp-mẫu cho các phần tử mong muốn (s) trong đó chế độ:

<xsl:apply-templates select="maml:alertSet/maml:alert" mode="copy-no-namespaces"/> 
+0

Mẫu đệ quy của bạn không hoạt động chính xác cho thuộc tính. Vì nó bây giờ nó sao chép thuộc tính vào phần tử chứa, nhưng nó cũng sao chép giá trị của thuộc tính dưới dạng văn bản. Bạn cần thay đổi '' sang ' '(thả' @ * ') –

Các vấn đề liên quan