RE: [xsl] chekcing attribute existance from a string

Subject: RE: [xsl] chekcing attribute existance from a string
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 1 May 2006 09:43:35 +0100
Given that you have a list of all the attribute names, your logic should be
something like:

<xsl:for-each select="$possibleAttributes">
  <td>
  <xsl:choose>
    <xsl:when test="row/@*[name()=current()]">
       <xsl:value-of select="row/@*[name()=current()]"/>
    </xsl:when>
    <xsl:otherwise>
       <xsl:text>(blank)</xsl:text> 

> -----Original Message-----
> From: jd list [mailto:jdlists@xxxxxxxxx] 
> Sent: 01 May 2006 00:22
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] chekcing attribute existance from a string
> 
> Hi.  This is likely a common issue, but can't seem to find 
> the right search terms to find assistance.
> 
> I'm trying to make a simple web page where a user can view a 
> html version of our xml config file.I have a set of 
> attributes in a particular node, not all of which are 
> required by the xsd and there are many of these nodes for 
> each parent node.
> 
> What i would like to do, for display, is get the list of all 
> possible attributes (done) and show those as a header (done), 
> and then display each node attributes as a table row, and 
> when i get to a node that only has a subset of the 
> attributes, skip any attribute that does not exist
> 
> the repeating nodes look like:
> <tag tag_type="timewave" integrate="aa" high_pass="0" interval="600"
> tag_id="707" comment="comment comment comment">
> 
> in this case i would want headers of
> tag_type integrate high_pass interval tag_id comment
> 
> in later rows that do not have a high_pass, for example how 
> do i skip that column.  i have all headers in
> 
> /path/to/tag[@tag_type='overall'][1]/@*
> 
> and was thinking of foreaching thoguht that same set to get 
> the others and trying a when 
> test="/path/to/tag/var[@var_id=$varId]/../../tag/name()".  
> where $varId is a variable from a higher level. the name() 
> portion is obviously illegal, but it illustrates what i'm 
> trying to do.  I want to check for the existance of an 
> attribute based on the result of name(), from the header list 
> and skip the column and move to the next.
> 
> Thanks for any assistance.  sorry so wordy....
> Jeff

Current Thread