0
XML 변환 작업을 시작하기 전에 변환 XML을 시작하기 전에 하위 요소 만 정렬했습니다. 나의 현재 XSL 파일 내가XSLT를 사용하여 XML 요소 정렬
를 정렬하고 싶지 않아 밖으로 정렬 자식 요소, 심지어 부모 요소는
내 XML 아래를 참조하시기 바랍니다
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Catalog>
<libraries>
<library3>
<Name> COBB </Name>
<city> Marietta </city>
</library3>
<library1>
<Name> COBB </Name>
<city> Marietta </city>
</library1>
<library4>
<Name> COBB </Name>
<city> Marietta </city>
</library4>
<library2>
<Name> COBB </Name>
<city> Marietta </city>
</library2>
</libraries>
<Books>
<Book1>
<Name>Wise Otherwise</Name>
<author>Great Expectations</author>
</Book1>
<Book3>
<Name>Wise Otherwise</Name>
<author>Great Expectations</author>
</Book3>
<Book6>
<Name>Wise Otherwise</Name>
<author>Great Expectations</author>
</Book6>
<Book2>
<Name>Wise Otherwise</Name>
<author>Great Expectations</author>
</Book2>
</Books>
</Catalog>
욕망 출력
<?xml version="1.0" encoding="UTF-8"?>
<Catalog>
<libraries>
<library1>
<city> Marietta </city>
<Name> COBB </Name>
</library1>
<library2>
<city> Marietta </city>
<Name> COBB </Name>
</library2>
<library3>
<city> Marietta </city>
<Name> COBB </Name>
</library3>
<library4>
<city> Marietta </city>
<Name> COBB </Name>
</library4>
</libraries>
<Books>
<Book1>
<author>Great Expectations</author>
<Name>Wise Otherwise</Name>
</Book1>
<Book2>
<author>Great Expectations</author>
<Name>Wise Otherwise</Name>
</Book2>
<Book3>
<author>Great Expectations</author>
<Name>Wise Otherwise</Name>
</Book3>
<Book6>
<author>Great Expectations</author>
<Name>Wise Otherwise</Name>
</Book6>
</Books>
</Catalog>
내 XSL
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Catalog/Books">
<xsl:copy>
<xsl:apply-templates select="node()">
<xsl:sort select="name()"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="Catalog/libraries">
<xsl:copy>
<xsl:apply-templates select="node()">
<xsl:sort select="name()"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
해결책이 있습니다. 주 노드 수준이 아닌 특정 요소를 정렬해야합니다. 내 XSL을 수정했습니다. Thanks –
'match = "Catalog/Books | Catalog/libraries"를 사용하여 마지막 두 개의 템플릿을 하나로 결합 할 수 있습니다. 솔루션을 직접 찾았 으면 문제를 해결하는 올바른 방법은 솔루션을 답변으로 게시하고 동의하는 것입니다. –