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

RE: please help. newbie needs help!!

Subject: RE: please help. newbie needs help!!
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Mon, 10 May 2004 22:58:37 -0600
column ss index
Understanding XPath goes beyond telling you how to get "THE WATHERSHED
GROUP, LLC" from your XML data.  There are many answers to this question
and it depends on various factors.  For example, will "THE WATHERSHED
GROUP, LLC" always be in the "Row" where ss:Index="2" or is it possible
it could be somewhere else.  

I do understand your frustration.  I was once new to the XSLT/XPath
world and although it didn't necessarily help me understand the
technology better sometimes the answer was what I needed first and a
lesson on how it works after.  As such I will give you the answer and
then a URI to where you can study up on XPath so that you can eliminate
some of your future frustrations by learning why this:

ta >

Will output:


Into your data stream coming from the XSLT processor.

Keep in mind that the above example starts from the wherever your XML
parser happens to be at the present moment.  So if you have created a
simple template and matched it to the root as such:

<xsl:template match="/">
ta >

Then you will get the proper result.  But if your match is set to
something deeper into your data such as "Workbook/Worksheet" the above
XPath will evaluate to nothing and therefore return nothing.  You can
change your context within your XML set various ways but the most common
way for someone first starting off in XSLT and XPath is within a
for-each loop.  If you were to have a for-each loop whose select
attribute was equal to "Workbook/Worksheet/Table/Row" and then try to
get the value of the Cell containing the company name using the XPath
from above it wouldn't work.

To better understand XSLT and XPath and not have to plow through a huge
number of pages that make little or no sense to the first time XSLT
developer I would highly recommend Dave Pawson's XSL FAQ.  It's a great
starting point to both answer the basic questions while give you
resources to find answers to the more difficult ones.  You can find it


Don't feel like you can't use this list as a resource.  Although I tend
to appear and disappear depending on my current workload there are a lot
of really great people in here who really know there stuff and find it a
pleasure to help those who need help getting things started or working
out difficult problems that can't be found in any of the references or
tutorials (well, they can be found, just not very easily to someone
unfamiliar with the technology).  I can advise you that doing a bit of
leg work on your own by first going to the archives of this list or
searching places like Dave Pawson's site or Jeni Tennison's site (
http://www.jenitennison.com/xslt/index.html ) will gain you a lot more
notice simply because it's encouraging to us to see that someone is
doing all they can to understand the technology before turning to
someone to just give them the answer.

Another recommendation if you know you will be doing a lot of work in
XSLT in the future.  Go to Amazon or whatever you prefer as far as
purchasing your tech books and find a copy of Michael Kay's XSLT
reference.  Here's the Amazon link...

He also has a 2.0 reference coming out although at the moment 2.0 has
not reached final recommendation and as such only has one XSLT processor
that supports it (Saxon, Michael Kay's XSLT processor.) So I would
probably avoid getting yourself confused with the difference between the
two until such time as your processors vendor releases support for the
2.0 recommendation (probably around the same time the W3C releases the
current draft, or a slighly modified version of it, as a final
recommendation.)  I tell you this because I would hate for you to
purchase (actually, you can only pre-purchase it, its hasn't been
officially released yet) the 2.0 reference thinking it was the latest
and greatest only to find out that your processor only supports 1.0.

I wish you the best of luck and encourage you to keep at it as far as
learning XSLT and XPath goes.  Like any other language it can be
difficult to learn at first but once you get it you get it and you'll be
happy you spent the time learning it as it is a VERY powerful tool.

Best regards,


-----Original Message-----
From: Jeremy Allen [mailto:jallen@xxxxxxxxxxxxxx] 
Sent: Monday, May 10, 2004 9:51 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  please help. newbie needs help!!

I need an xpath expression for getting data from this xml, for example
expression would I use to get the string "THE WATERSHED GROUP, LLC"? Any
help appreciated!!!

<?xml version="1.0"?>
    <Author>PC Entry</Author>
    <LastAuthor>PC Entry</LastAuthor>
  <OfficeDocumentSettings />
    <Style ss:ID="Default" ss:Name="Normal">
      <Alignment ss:Vertical="Bottom" />
    <Style ss:ID="s21">
      <NumberFormat ss:Format="Short Date" />
    <Style ss:ID="s22">
      <NumberFormat ss:Format="Fixed" />
  </Styles>  <Worksheet ss:Name="Sheet1">
      <Column ss:Index="1" ss:Width="315"/>
      <Column ss:Index="2" ss:Width="153"/>
      <Column ss:Index="3" ss:Width="297"/>
      <Column ss:Index="4" ss:Width="126"/>
      <Column ss:Index="5" ss:Width="126"/>
      <Column ss:Index="6" ss:Width="72"/>
      <Column ss:Index="7" ss:Width="90"/>
      <Column ss:Index="8" ss:Width="108"/>
      <Row ss:Index="1">
        <Cell ss:Index="1" >
          <Data ss:Type="String">111-55555</Data>
      <Row ss:Index="2">
        <Cell ss:Index="1" >
          <Data ss:Type="String">THE WATERSHED GROUP, LLC</Data>
      <Row ss:Index="3">
        <Cell ss:Index="1" >
          <Data ss:Type="String">GUS'S WATERSHED</Data>

Current Thread


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.
First Name
Last Name
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.