필자가 작성한 변환은 주어진 노드 집합에서 쉼표로 구분 된 문자열 값을 작성해야합니다. 결과 문자열은 입력 값의 첫 번째 문자에 대한 무작위 (비 알파벳) 매핑에 따라 정렬되어야합니다. 필드 하위 문자열을 사용하는 XSL 연관 정렬
나는이 함께했다 :<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tmp="http://tempuri.org"
exclude-result-prefixes="tmp"
>
<xsl:output method="xml" indent="yes"/>
<tmp:sorting-criterion>
<code value="A">5</code>
<code value="B">1</code>
<code value="C">3</code>
</tmp:sorting-criterion>
<xsl:template match="/InputValueParentNode">
<xsl:element name="OutputValues">
<xsl:for-each select="InputValue">
<xsl:sort select="document('')/*/tmp:sorting-criterion/code[@value=substring(.,1,1)]" data-type="number"/>
<xsl:value-of select="normalize-space(.)"/>
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
그것은 일을하고 내가 예상대로 평가하지 않습니다는 XPath document('')/*/tmp:sorting-criterion/code[@value=substring(.,1,1)]
처럼 보이는하지 않습니다. 나는 substring(.,1,1)
을 리터럴로 대체했는지 확인하고 적절한 값으로 평가합니다.
그래서 XPath 표현식을 예상대로 평가하지 못하거나 단순히 이런 방식으로 처리 할 수없는 것이 있습니까?
작동하는 XPath 식을 만들 수 없다면 목표를 달성하기위한 해결 방법이 있습니까?
참고 :
<?xml version="1.0" encoding="utf-8"?>
<InputValueParentNode>
<InputValue>A input value</InputValue>
<InputValue>B input value</InputValue>
<InputValue>C input value</InputValue>
</InputValueParentNode>
예상 OUPUT : 내가 샘플 입력이
XSLT - 1.0
으로 제한하고있어<?xml version="1.0" encoding="utf-8"?>
<OutputValues>B input value,C input value,A input value</OutputValues>
당신은 예를 들어, 입력 및 예상 출력을 제공 할 수 있을까요? – wdebeaum
@wdebeaum : 질문 모두를 포함하도록 편집되었습니다. 건배. –