Reputation: 24399
I tried searching for my issue on here and was unsuccessful.
<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>
I have two for-each statements checking my XSD for a true or false value:
<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"/>
The above is not working for me. I've also tried true()/false()
which seemed to have failed as well.
Am I missing something obvious?
Edit: The boolean values are checkboxes in Alfresco CMS, so I can't simply check it's existence but rather whether it's true or false.
<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>
Upvotes: 0
Views: 2515
Reputation: 60448
Compare against the values 'true' and 'false' as well as '1' and '0':
$all_events[(g:active = 'true') or (g:active = 1)]
Because the possible values of an xs:boolean
element are those four values.
In XPath 2.0 you would be able to cast them using the boolean()
function. Since that doesn't work for you I'm assuming you're using XPath 1.0.
Upvotes: 1