2010-07-27 5 views
0

여기에서 내 문제를 검색해 보았는데 실패했습니다. 위의XSLT 부울 값

<xs:simpleType name="confirm"> 
     <xs:restriction base="xs:boolean"/> 
</xs:simpleType> 

<xs:element name="active" type="g:confirm" minOccurs="0"/> 
<xs:element name="current" type="g:confirm" minOccurs="0"/> 

중동 작동하지 않습니다 :

<xsl:for-each select="$all_events[g:active = 1]"> 
     <xsl:sort select="g:event_date" order="descending"/> 
     <xsl:variable name="fileName"><xsl:value-of select="fn:replaceAll(string(@alf:file_name), '.xml', '.html')"/></xsl:variable> 
     <xsl:variable name="fileURL"><xsl:value-of select="concat('/events/', $fileName)" /></xsl:variable> 
     <xsl:variable name="fileDate"><xsl:value-of select="g:event_date" /></xsl:variable> 
     <xsl:variable name="date"><xsl:value-of select="substring($fileDate, 6, 2)" /></xsl:variable> 
     <li><a href="{$fileURL}"><xsl:value-of select="g:event_title"/></a></li> 
    </xsl:for-each> 
    </ul><br/> 
    <xsl:for-each select="$all_events[g:body/g:current = 1]"> 
     <xsl:for-each select="g:body"> 
      <h2 class="normal"><xsl:value-of select="g:sub_title" /></h2> 
       <xsl:for-each select="g:paragraphs"> 
        <xsl:value-of select="g:paragraph" disable-output-escaping="yes"/> 
       </xsl:for-each> 
     </xsl:for-each> 
    </xsl:for-each> 

나는 두 가지가-각각 true 또는 false 값을 내 XSD를 확인 문이있다. 나는 또한 실패한 것처럼 보인 true()/false()을 시도했다.

나는 분명한 뭔가를 놓치고 있습니까?

편집 : 부울 값은 Alfresco CMS의 체크 박스로, 단순히 존재 여부 만 확인할 수는 없으며 오히려 참인지 거짓인지를 확인할 수 있습니다.

<xs:simpleType name="confirm"> 
     <xs:restriction base="xs:boolean"/> 
</xs:simpleType> 
<xs:element name="content"> 
    <xs:complexType> 
     <xs:sequence> 
      <xs:element name="page_title" type="xs:normalizedString" minOccurs = "0"> 
       <xs:annotation> 
        <xs:appinfo> 
         <alf:appearance>title</alf:appearance> 
        </xs:appinfo> 
       </xs:annotation> 
      </xs:element> 
      <xs:element name="event_title" type="xs:normalizedString" minOccurs = "0"> 
       <xs:annotation> 
        <xs:appinfo> 
         <alf:appearance>title</alf:appearance> 
        </xs:appinfo> 
       </xs:annotation> 
      </xs:element> 
      <xs:element name="active" type="g:confirm" minOccurs="0"/> 
      <xs:element name="event_date" type="xs:date" /> 
      <xs:element name="body" minOccurs="0" maxOccurs="unbounded"> 
       <xs:complexType> 
        <xs:sequence> 
         <xs:element name="sub_title" type="xs:normalizedString" minOccurs = "0"> 
          <xs:annotation> 
           <xs:appinfo> 
            <alf:appearance>title</alf:appearance> 
           </xs:appinfo> 
          </xs:annotation> 
         </xs:element> 
         <xs:element name="current" type="g:confirm" minOccurs="0"/> 
         <xs:element name="paragraphs" minOccurs="0" maxOccurs="unbounded"> 
          <xs:complexType> 
           <xs:sequence> 
            <xs:element name="paragraph" type="xs:string" minOccurs = "0"> 
             <xs:annotation> 
              <xs:appinfo> 
               <alf:appearance>custom</alf:appearance> 
              </xs:appinfo> 
             </xs:annotation> 
            </xs:element> 
           </xs:sequence> 
          </xs:complexType> 
         </xs:element> 
        </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
</xs:element> 
</xs:schema> 

답변

1

비교 대상 값 '참'과 '거짓'뿐만 아니라 '1'과 '0'일 : xs:boolean 요소의 가능한 값이 그 네 개의 값이기 때문에

$all_events[(g:active = 'true') or (g:active = 1)] 

.

XPath 2.0에서는 boolean() 함수를 사용하여 캐스팅 할 수 있습니다. 그게 당신을 위해 작동하지 않기 때문에 XPath 1.0을 사용하고 있다고 가정하고 있습니다.

+0

이렇게'$ all_events [부울 (g : 활성) = 1]'? – balexander

+0

아니요. 그런 비교가 필요 없습니다. '$ all_events [boolean (g : active)]'는 잘 할 것입니다. 어떤것을 비교할 필요가 있다면'$ all_events [boolean (g : active) = true()]'와 같은 실제 부울 값과 비교하십시오. 다시 말하지만, 그럴 필요는 없습니다. – Welbog

+0

나는 그것이 true인지 false인지를 지정해야한다고 생각한다. 왜냐하면 지금 체크 박스가 체크되었는지 아닌지가 표시되기 때문이다. 'true()'를 추가 한 이벤트가 작동하지 않았습니다. – balexander