xml - How to compare node attribute against node -


i trying figure out how similar `if exists in (node)

i have following xml , on xls i´m tryingto compare if available flags @id exists in contact/biographical/flags

<availableflags>         <flag id="happy">happy</flag>         <flag id="curious">curious</flag>         <flag id="busy">busy</flag>         <flag id="expert">expert</flag>         <flag id="client">client</flag>         <flag id="manager">manager</flag>     </availableflags>  <contact>          <biographical>             <age>33</age>             <flags>                 <flag>happy</flag>                 <flag>expert</flag>             </flags>         </biographical>         <contact> 

xls

   <xsl:if test="@id=contact/biographical/flags/@flag">         <input type="checkbox"  checked="checked"> <xsl:text>{contact/biographical/flags/@flag}</xsl:text>     </input>              </xsl:if> 

i have tried different variations of if statement, no luck. hoping might kind , me out. thanks

if current context flag element need navigate tree bit reach contact element. flag in contact section element, not attribute

<xsl:if test="@id=../../contact/biographical/flags/flag">   <input type="checkbox" checked="checked">     <xsl:value-of select="." />   </input> </xsl:if> 

but more generally, looks you're trying render checkboxes each available flag, selected ones checked. in case easier make attribute conditional rather whole element:

<input type="checkbox">   <xsl:if test="@id=../../contact/biographical/flags/flag">     <xsl:attribute name="checked">checked</xsl:attribute>   </xsl:if>   <xsl:value-of select="." /> </input> 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -