Re: [xsl] chekcing attribute existance from a string

Subject: Re: [xsl] chekcing attribute existance from a string
From: "jd list" <jdlists@xxxxxxxxx>
Date: Tue, 2 May 2006 00:30:49 +0000
Thanks Michael, that got me closer. but am still confused

my for-each select is
/aroot/hub/derivation[@derive_type='overall'][1]/@* ( this type is
always has all attributes)

i then need to select a node based on an id, which is passed in, to
find out if this attribute exists and what its value is,
<xsl:param name="measId" />
and i try this in the when test
<xsl:when
test="/aroot/hub/derivation/var[@meas_id=$measId]/../@*[name()=current()]"

name() holds the attribute name and current() the attribute value, so
they are never equal.

on the other hand, if i make the value-of select= and when test=, only
@*[name()] or @*[current()], i get the first value of the first
attribute of my for-each select query. I can not seem to access any
variables in a query like...
/aroot/hub/derivation/var[@meas_id=$measId]/../@*[name()].

if i hard code the end value i get the attribute as expected
/aroot/hub/derivation/var[@meas_id=$measId]/../@comment

could you explain what you're accomplishing with @*[name()=current()],
in both the test and select? or possibly point me to some
documentation that may explain it....i feel like i'm missing something
obvious.  also ...I feel like i'm iterating through the wrong loop as
well and that i making it more difficult that it needs to be.

Thanks,
Jeff


ps. your xslt2 (wrox) book has been very helpful.





On 5/1/06, Michael Kay <mike@xxxxxxxxxxxx> wrote:
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