XSLT를 구현할 때이 문제점에 대한 도움이 필요하므로 SAX 파서를 사용하여이 Java 코드를 이미 구현했지만 사용자가 무언가를 변경해야한다는 번거 로움이 있습니다. .XSLT : 계속 분할하지 않음 요소/그룹화 계속됨 요소
이제 XSLT를 사용하여 컴파일하고 웹 서버에 배포 할 필요가 없습니다. 나는 아래와 같은 XML을 가지고있다.
예 1
<ShotRows>
<ShotRow row="3" col="3" bit="1" position="1"/>
<ShotRow row="3" col="4" bit="1" position="2"/>
<ShotRow row="3" col="5" bit="1" position="3"/>
<ShotRow row="3" col="6" bit="1" position="4"/>
<ShotRow row="3" col="7" bit="1" position="5"/>
<ShotRow row="3" col="8" bit="1" position="6"/>
<ShotRow row="3" col="9" bit="1" position="7"/>
<ShotRow row="3" col="10" bit="1" position="8"/>
<ShotRow row="3" col="11" bit="1" position="9"/>
</ShotRows>
출력 1 :
<ShotRows>
<ShotRow row="3" colStart="3" colEnd="11" />
</ShotRows>
<!-- because the col is continuous from 3 to 11 -->
예 2
<ShotRows>
<ShotRow row="3" col="3" bit="1" position="1"/>
<ShotRow row="3" col="4" bit="1" position="2"/>
<ShotRow row="3" col="6" bit="1" position="3"/>
<ShotRow row="3" col="7" bit="1" position="4"/>
<ShotRow row="3" col="8" bit="1" position="5"/>
<ShotRow row="3" col="10" bit="1" position="6"/>
<ShotRow row="3" col="11" bit="1" position="7"/>
<ShotRow row="3" col="15" bit="1" position="8"/>
<ShotRow row="3" col="19" bit="1" position="9"/>
</ShotRows>
출력 2 :
<ShotRows>
<ShotRow row="3" colStart="3" colEnd="4" />
<ShotRow row="3" colStart="6" colEnd="8" />
<ShotRow row="3" colStart="10" colEnd="11" />
<ShotRow row="3" colStart="15" colEnd="15" />
<ShotRow row="3" colStart="19" colEnd="19" />
</ShotRows>
기본 아이디어는 모든 연속 된 열을 하나의 요소로 그룹화하는 것입니다 (예 : 열 3 - 4, 열 6 - 8, 열 10 - 11, 열 15는 하나 뿐이지 열 19는 하나임). 미리 감사드립니다.
간단하고 우아한 +1.:) – Tomalak
XSLT 2.0은 Saxon.NET을 통해 .NET에서도 사용할 수 있습니다. –
자바에서 Saxon 9.1을 사용하고 있습니다 – Gerald