tags:

views:

21

answers:

1

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>
A: 

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.

Welbog
So like this `$all_events[boolean(g:active) = 1]` ?
Bry4n
No. There's no need for any comparisons like that. `$all_events[boolean(g:active)]` will do fine. If you need to compare something, compare to an actual boolean value, like this: `$all_events[boolean(g:active) = true()]`. Again, that is not necessary.
Welbog
I believe I have to specify whether it's true or false because now whether the checkbox is checked or not it displays. Event adding `true()` didn't work.
Bry4n
How about you give me a sample of your source document so I can see for myself what you're working with?
Welbog
I added parts from both my XSD and XSLT. They tie in with Alfresco CMS as a Web Form and create checkboxes. Which source document are you referring to?
Bry4n
The one you're operating on.
Welbog
Thank you that worked! Thanks for helping me with my previous issue as well. Much appreciated!
Bry4n