The data() function returns the typed value of its argument
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
<xsl:import-schema>
<xs:schema>
<xs:element name="person" type="person" />
<xs:complexType name="person">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="married" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
</xsl:import-schema>
<xsl:variable name="input">
<person xsl:type="person" married="false">typed singleton</person>
<person married="false">singleton</person>
</xsl:variable>
<xsl:template match="/" name="main">
<xsl:for-each select="$input/person">
<xsl:value-of select="concat('
',.)" />
<xsl:if test="data(@married)"> - married</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
<xsl:import-schema>
<xs:schema>
<xs:element name="person" type="person" />
<xs:complexType name="person">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="married" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
</xsl:import-schema>
<xsl:variable name="input">
<person xsl:type="person" married="false">typed singleton</person>
<person married="false">singleton</person>
</xsl:variable>
<xsl:template match="/" name="main">
<xsl:for-each select="$input/person">
<xsl:value-of select="concat('
',.)" />
<xsl:if test="data(@married)"> - married</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>