는 어떻게 출력 모든 노드를 뺀 특정 노드와 노드의 하위 트리을에 :
이 변환 (없음이 제공되지 않았습니다!) 다음과 같은 XML 문서에 적용
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="example[. = 'Some text']"/>
</xsl:stylesheet>
:
<a>
<example>Some different text</example>
<b>
<c>
<example>Some text</example>
</c>
<example>Some other text</example>
</b>
</a>
원하는 올바른 결과가 생성됩니다. :
01 여기 23,516,<a>
<b>
<c></c>
</b>
</a>
만 원하는 노드와 노드의 서브 트리을 추출하는 방법입니다 :
<example>Some text</example>
: 같은 XML 문서 (위), 결과는 지금입니다 적용
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="example[. = 'Some text']">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
하나의 XSLT 1.0 변환에서 두 가지 다른 결과 문서를 생성 할 수 없습니다.
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vResult2">
<xsl:apply-templates mode="result2"/>
</xsl:variable>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="example[. = 'Some text']"/>
<xsl:template match="/">
<xsl:apply-templates/>
<xsl:result-document href="file:///c:/temp/delete/result2.xml">
<xsl:sequence select="$vResult2"/>
</xsl:result-document>
</xsl:template>
<xsl:template mode="result2" match="example[. = 'Some text']">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template mode="result2" match="text()"/>
</xsl:stylesheet>
이 태그와 소스 XML 여러 노드이며, I는를 찾아야 : 여기 노드. 이 노드 만 추출하고이 특정 텍스트가 "일부 텍스트"이고 다른 노드가 이 아닌 노드를 추출하려면 어떻게합니까? –
user840930
는 1 결과를 출력하고, 파일에 초 결과를 쓰는 XSLT 2.0 변환이고 특정 텍스트 "일부 텍스트"가있는 노드
@ user840930 : 질문을 편집하고 모든 관련 정보를 제공해주십시오. 다음 번에는 질문을 좀 더 세 심하게 배웁니다. 귀하의 의견을 반영하도록 답변을 업데이트했습니다. –