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

RE: XPath weirdness!!

Subject: RE: XPath weirdness!!
From: "Crowers, Steve" <scrowers@xxxxxxxxxxxx>
Date: Wed, 25 Jul 2001 15:20:48 -0400
buffer spatialquery
Ok, I'm not sure exactly what you're doing here (It seems that it would be
easier to select the Buffer elements in a template and the process the Point
elements from there but assuming that there is a reason for doing the
choose, try this:

<xsl:template match="SpatialQuery">
 <xsl:choose>
  <xsl:when test="Buffer">
   <MULTIPOINT>
   <xsl:for-each select="Buffer/Point">
    <POINT x="{@x}" y="{@y}"/>
   </xsl:for-each>
   </MULTIPOINT>
  </xsl:when>
 </xsl:choose>
</xsl:template>

you still shouldn't be using the "//" operator, though...  In my for-each
you are getting a RTF with the point elements under the current node.  If
you do 'for-each select="//Point"', you will be getting *EVERY* Point
element in the source document (see about a million posts from Mike Kay
regarding this).

I hope this helps out some...

Steve Crowers
Software Engineer


Liberate Technologies
2 Walnut Grove,
Suite 200
Horsham, PA 19044
Phone: 215-773-9400 x 9514
Fax: 215-773-9401
scrowers@xxxxxxxxxxxx
http://www.liberate.com



-----Original Message-----
From: Kris Kolodziej [mailto:kkolodziej@xxxxxxxxxxxx]
Sent: Wednesday, July 25, 2001 2:02 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  XPath weirdness!!


OK. I hope I can be more clear with this email.

Here is part of my XML source:
<Query>
  <SpatialQuery>
   <Buffer distance="100" units="miles">
    <Point x="-122.5281" y="37.635" />
    <Point x="-122.4521" y="37.700" />
    <Point x="-122.4000" y="37.750" />
    <Point x="-122.3100" y="37.820" />
   </Buffer>
  </SpatialQuery>
 </Query>

I want this part of the output to be:
 <MULTIPOINT>
       <POINT x="-122.5281" y="37.635" />
       <POINT x="-122.4521" y="37.700" />
       <POINT x="-122.4000" y="37.750" />
       <POINT x="-122.3100" y="37.820" />
</MULTIPOINT>


This is part of the XSL that I am using to transform the above:
<xsl:when test="//SpatialQuery/Buffer">
<!-- I need the "//" to get back the <MULTIPOINT> and <POINT> tags -->
   <MULTIPOINT>
          <xsl:for-each select="//Point">
                <POINT>
                <xsl:attribute name="x">
                        <xsl:value-of select="//@x"/>  <!--
THIS GIVES ME THE "X" values -->
                </xsl:attribute>
                <xsl:attribute name="y">
                        <xsl:value-of select="/@y"/>   <!-- HERE IF I USE
"//@y" I GET THE "

&x#3c" ERROR -->
                </xsl:attribute>
               </POINT>
        </xsl:for-each>
    </MULTIPOINT>
</xsl:when>


Julian Reschke wrote:

> I'm not sure what the problem that reported is... But:
>
> *why* are you using the // syntax at all?
>
> "//@y" finds *all* attributes named "y" in the document, and then returns
> the text value of the first one (AFAIK). Is this *really* what you want?
>
> If you clearly describe what you source format is and which output you
need,
> people on the list will be able to suggest much better (and faster) XSLT
> code...
>
> > -----Original Message-----
> > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Kris
> > Kolodziej
> > Sent: Wednesday, July 25, 2001 7:14 PM
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  XPath weirdness!!
> >
> >
> > This is related to my previous problem with the "&x#3c." So I figured
> > out that I was doing something wrong with the XPath locations...However,
> > now I am experiencing some weird things with XPath. Take the following
> > example for instance:
> >
> > This works but it only give me the "x" value (and I sure do want to get
> > both x AND y).
> > Notice that for "y" I only have "/@y". This is because when I do the
> > same thing as I did for "x" (meaning writing   "<xsl:value-of
> > select="//@y"/>" )  I get the "&x#3c" error!!! WHY??!
> >
> >
> >  <xsl:when test="//SpatialQuery/Buffer">
> >    <MULTIPOINT>
> >           <xsl:for-each select="//Point">
> >                 <POINT>
> >                 <xsl:attribute name="x">
> >                         <xsl:value-of select="//@x"/>
> >                 </xsl:attribute>
> >                 <xsl:attribute name="y">
> >                         <xsl:value-of select="/@y"/>
> >                 </xsl:attribute>
> >                </POINT>
> >         </xsl:for-each>
> >     </MULTIPOINT>
> >
> >
> > It also works when I do the vice versa of what I have ("/@x" and "//@y")
> > but I can't have it written the same way.
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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

 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.