1
형제로 뒤에 오는 태그 <C>
이 하나 이상있는 경우 내 태그 <T>
만 변형 될 XML이 있습니다.특정 태그가 다음 형제에 존재하는 경우 태그 일치
<Doc>
<T>T1</T>
<A>A1</A>
<T>T2</T>
<C>C2</C>
<T>T3</T>
<X>X1</X>
</Doc>
이 될해야합니다 T1A1T2C2X1
을 내가 현재 가지고 :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:element name="Doc">
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<xsl:template match="A">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="C">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="X">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="T[following-sibling::* ??? exists C">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="*">
</xsl:template>
</xsl:stylesheet>
match="T[following-sibling::* ??? exists C"
나는 샘플 XML은 ** C가 있다면이 올바른 결과를주지 않을 것이라고 생각 ** 매우 첫 번째 자식 요소로 요소입니다. –
@TimC, 감사합니다. 편집 됨. –
감사. 내가 원래 가지고 있었기 때문에 A, C 및 X에 대한 특정 규칙을 사용하고 나머지는 무시하고 다른 모든 태그를 무시하는 방법이 있습니까? – stracktracer