Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] chekcing attribute existance from a string

From: "jd list" <jdlists@--------->
To:
Date: 5/2/2006 12:31:00 AM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent