[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XPath Question Get Attribute

Subject: Re: XPath Question Get Attribute
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 9 Oct 2002 16:45:22 +0100
xpath get attribute value
Hi Scott,

> I have a xml file that looks like this:
>
> <imageInfo>
>    <psd width="288">
>         <other stuff>
>         </other stuff>
>         <layer name="Blue" type="pixel" top="84" left="83" right="211" bottom="206" />
>    </psd>
> </imgeInfo>
>
> I want to programatically change the top from '84' to '0' but I am
> struggline. The next three lines are some I have. The first two
> work, and actually are successful. But I cannot figure out how to
> set another attribute eg 'top' value.
>
> <set target="/psd/layer[@name='Green']/@visibility" value="hidden" />  <!-- works great -->
> <set target="/psd/layer[@name='Blue']/@opacity" value=".5" />            <!-- works great -->
> <set target="/psd/layer[@name='Blue']["top" value="0.0"] />   <!-- have no clue how to set the top value.

The last one there isn't even well-formed XML. I think that you want
to follow the same pattern as the previous two, and use:

  <set target="/psd/layer[@name='Blue']/@top" value="0.0" />

don't you?

> PS, Why the @name and @visibility and @opacity. What does the @
> represent?

In XPath, '@' is a shorthand for specifying the attribute axis. For
example:

  psd/layer

would give you the 'layer' child *element* of psd, whereas:

  psd/@layer

would give you the 'layer' *attribute* of psd.

By the way, what application are you using these XPaths in? It doesn't
look like it's XSLT...

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.