2013-10-18 2 views
1

XSLT 함수를 통해 특정 요소/속성을 변환하는 것에 대해 많은 것을 알았습니다. translate (source, sourceChars, outputChars) translate ("čašaž", "čšž", "csz") = casazXSLT를 통해 전체 XML 문서에서 분음 기호 제거

각 노드와 각 속성을 변환하는 XSLT 템플릿이 필요합니다. 소스 XML의 구조를 모르므로, 속성 또는 요소 이름과 값에 보편적 인 비 독점적이어야합니다.

나는이 의사 변환 같은 것을 찾고 있어요 : 당신은 내가 아래에 당신이 정상화하려는 데이터를 포함하는 요소에 대한 템플릿을 작성할 수 있습니다

<xsl:template match="@*"> 
    <xsl:copy> 
     <xsl:apply-templates select="translate(. , "čžš","czs")"/> 
    </xsl:copy> 
    </xsl:template> 

    <xsl:template match="node()"> 
    <xsl:copy> 
     <xsl:apply-templates select="translate(. , "čžš","czs")"/> 
    </xsl:copy> 
    </xsl:template> 

답변

2

그 속성 값, 텍스트 노드, 주석 노드 및 처리 명령 데이터.

<xsl:param name="in" select="'čžš'"/> 
<xsl:param name="out" select="'czs'"/> 

<xsl:template match="*"> 
    <xsl:copy> 
    <xsl:apply-templates select="@* | node()"/> 
    </xsl:copy> 
</xsl:template> 

<xsl:template match="@*"> 
    <xsl:attribute name="{name()}" namespace="{namespace-uri()}"> 
    <xsl:value-of select="translate(., $in, $out)"/> 
    </xsl:attribute> 
</xsl:template> 

<xsl:template match="text()"> 
    <xsl:value-of select="translate(., $in, $out)"/> 
</xsl:template> 

<xsl:template match="comment()"> 
    <xsl:comment> 
    <xsl:value-of select="translate(., $in, $out)"/> 
    </xsl:comment> 
</xsl:template> 

<xsl:template match="processing-instruction()"> 
    <xsl:processing-instruction name="{name()}"> 
    <xsl:value-of select="translate(., $in, $out)"/> 
    </xsl:processing-instruction> 
</xsl:template>