XML 문서의 일괄 처리에 XSLT 변환을 적용하려고합니다. 변환의 핵심은 여러 요소를 재정렬하는 것입니다. 너무 많은 의견을 잡고xslt & xpath : 직전의 설명과 일치합니다.
<xsl:template match="element">
<xsl:copy-of select="preceding-sibling::comment()"/>
</xsl:template>
: 나는 솔루션에 왔어요 가장 가까운 표현을 사용하는 것입니다
<!-- not this comment -->
<element />
<!-- this comment -->
<!-- and this one -->
<element />
: 나는 직접가 요소보다 우선 의견을 유지하고자하는
<!-- not this comment -->
<!-- this comment -->
<!-- and this one -->
필자는 앞서 언급 한 XPath가 올바르게 작동하지 않는 이유를 알고 있지만 진행 방법에 대한 좋은 아이디어가 없습니다.
preceding-sibling::comment()[following-sibling::reference_to_current_element() or following-sibling::comment()]
감사 솔루션은 완벽하게 작동합니다! 나는 generate-id()와 key()에 대해 읽어야 할 것이다. –
@ Joshua Johnson : 키들에 관해서 : 저는 JavaScript의 예제에서 어떻게 작동하는지 설명하는 것을 작성했습니다. 원하는 경우 살펴보십시오. http://stackoverflow.com/questions/948218/xslt-3-level- grouping-on-attributes/955527 # 955527 (대답의 아래 부분 만 읽음). – Tomalak