2017-11-22 3 views
0

내에서 태그 값을 추출하는 데 문제가 있습니다. xsl : variable 안에 있습니다. sample createdxsl : variable 내에서 textnode 값을 추출하십시오.

XML

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl"> 
    <xsl:output omit-xml-declaration="yes" encoding="utf-16" 
     indent="yes" /> 

    <xsl:template name="barTemplate" match="Result/resultDetails"> 
     <xsl:call-template name="fooTemplate"/> 
    </xsl:template> 
    <xsl:template name="fooTemplate"> 
     result -- <xsl:value-of select="$allFooList"/> -- 
     result -- <xsl:value-of select="$allFooList/fooMap/fooList[UsedBy='hola']/Code[normalize-space(@fooValue)=normalize-space('CNS')]/@barValue"/> -- 
    </xsl:template> 

    <xsl:variable name="allFooList" > 
     <fooMap> 
      <fooList> 
       <UsedBy>hola</UsedBy> 
       <Code fooValue="LP" barValue="Linkin" >We love Chester</Code> 
       <Code fooValue="LP" barValue="Park" /> 
      </fooList> 
     </fooMap> 
    </xsl:variable> 

</xsl:stylesheet> 

내 목표는 두 번째 결과 인쇄에서 "우리는 체스터 사랑 "를 추출하고 인쇄하는 것입니다

<Result> 
    <resultDetails> 
    <resultDetailsData> 
     <itemProperties> 
     <ID>1</ID> 
     <type>LEVEL</type> 
     <value>5</value> 
     </itemProperties> 
    </resultDetailsData> 
    </resultDetails> 
</Result> 

XSL. 이제 인쇄용 블랭크.

내가 뭘 잘못하고 있니? 그럼이 요소에 우선을위한

+2

XSLT 1 프로세서를 사용하는 경우 변수는 결과 집합 트리가 아니라 노드 집합입니다. '$ allFooList/fooMap/... '을 시도 할 때 에러가 발생하지 않습니까? 이러한 값을 하드 코딩하려면 XSLT 네임 스페이스와 다른 네임 스페이스의 최상위 요소에 넣을 수 있습니다. '문서 ('')/*/ns : fooMap/ns : fooList/...'. 또는 XSLT 1 프로세서가 지원하는 확장 기능에 따라'exsl : node-set ($ allFooList)/fooMap/... '또는 유사한 것을 사용해야합니다. –

답변

0

: 공백을 정상화에도

<Code fooValue="LP" barValue="Linkin" >We love Chester</Code> 

@fooValue이 아닌, 'CNS'를 동일 않습니다.

또한 XSLT 1.0에서는 이전 주석에서 지적한대로 결과 트리 조각 내부에서 노드를 선택할 수 없습니다.