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

Re: Can I use Axes from Attribute Context Node?

Subject: Re: Can I use Axes from Attribute Context Node?
From: "S.Ramaswamy" <srswamy@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 02 Dec 1999 07:45:47 +0530
ancestor for each context

> Your code is broadly correct. The only thing wrong with it is that
> <browseList> is not, in your example, an ancestor of the relevant attribute
> node. Also I think it would be clearer if you wrote
> ancestor::something/browseList/MxColumn/text().

Yes there is a root element MxDOM which I missed in this post. I have it in my
program however.

> You haven't said what product you are using, as the failure is a ClassCast
> it looks to me like a bug in the product.

I am using LotusXSL 0.18.5. Subsequently, I wrote an intermediate XSL that
converted all the attributes of the node to elements. That is

Old XML
=======
<browseList>
    <MxColumn>SUBCODE</MxCOlumn>
    <MxColumn>SUBDESC</MxColumn>
 </browseList>
 ...............
 ...............
 <bookhouse>
   <SUBJECT>
     <row SUBCODE="ANM" SUBDESC="Animal Science"  CREATEDATE="1999-10-10"
CREATEBY"BABY" />
     <row SUBCODE="COM" SUBDESC="Computer Science"  CREATEDATE="1998-12-10"
CREATEBY"XYZ" />
     <row SUBCODE="BIO" SUBDESC="Biology" CREATEDATE="1999-01-05" CREATEBY"ABC"
/>
     <row SUBCODE="GEO" SUBDESC="Geography" CREATEDATE="1999-08-13"
CREATEBY"BABY" />
   </SUBJECT>
 </bookhouse>


New XML
=======

<browseList>
    <MxColumn>SUBCODE</MxCOlumn>
    <MxColumn>SUBDESC</MxColumn>
 </browseList>
 ...............
 ...............
 <bookhouse>
   <SUBJECT>
     <row>
       <SUBCODE>ANM</SUBCODE>
       <SUBDESC>Animal Science</SUBDESC>
       <CREATEDATE>1999-10-10</CREATEDATE>
       <CREATEBY>BABY</CREATEBY>
         </row>
    <row>
       <SUBCODE>COM</SUBCODE>
       <SUBDESC>Computer Science</SUBDESC>
       <CREATEDATE>1998-12-10</CREATEDATE>
       <CREATEBY></CREATEBY>
       </row>
   .... other rows .....

  </SUBJECT>
 </bookhouse>

 With the new XML, Now I am able to select

  bookhouse/SUBJECT/row/SUBCODE and
  bookhouse/SUBJECT/row/SUBDESC

 because these occur under
   /bookhouse/MxColumn

using

   <xsl:for-each select="/bookhouse/SUBJECT/row">
     <xsl:for-each select="*">
               <!--   @* gives error and This works -->
       <xsl:variable name="columnName"
          select="ancestor::MxDOM/browseList/MxColumn/." />

        <xsl:if test='name()=$columnName'>
         <xsl:value-of select=current() />
       </xsl:if>
      </xsl:for-each>
    </xsl:for-each>


Is it a bug (that you cannot traverse the Document using Axes when the context
node is an attribute). then in LotusXSL 0.18.5?

> > -----Original Message-----
> > From: S.Ramaswamy [mailto:srswamy@xxxxxxxxxxxxxxxxxxxx]
> > Sent: 25 November 1999 23:34
> > To: xsl-list@xxxxxxxxxxxxxxxx
> > Subject: Can I use Axes from Attribute Context Node?
> >
> >
> > I have the following XML fragment
> >
> > <browseList>
> >    <MxColumn>SUBCODE</MxCOlumn>
> >    <MxColumn>SUBDESC</MxColumn>
> > </browseList>
> > ...............
> > ...............
> > <bookhouse>
> >   <SUBJECT>
> >     <row SUBCODE="ANM" SUBDESC="Animal Science"
> > CREATEDATE="1999-10-10"
> > CREATEBY"BABY" />
> >     <row SUBCODE="COM" SUBDESC="Computer Science"
> > CREATEDATE="1998-12-10" CREATEBY"XYZ" />
> >     <row SUBCODE="BIO" SUBDESC="Biology" CREATEDATE="1999-01-05"
> > CREATEBY"ABC" />
> >     <row SUBCODE="GEO" SUBDESC="Geography" CREATEDATE="1999-08-13"
> > CREATEBY"BABY" />
> >   </SUBJECT>
> > </bookhouse>
> >
> > What I am trying to do
> > ======================
> >
> > I want to select
> >
> >   bookhouse/SUBJECT/row/@SUBCODE and
> >   bookhouse/SUBJECT/row/@SUBDESC
> >
> > because these occur under
> >   /bookhouse/MxColumn
> >
> > Code I have tried
> > =================
> >
> > <xsl:for-each select="/bookhouse/SUBJECT/row">
> >  <xsl:for-each select="@*">
> >    <xsl:variable name="columnName"
> > select="ancestor::browseList/MxColumn/." />
> >    <!-- error on the above line ClassCast cannot cast to
> > TXAttribute -->
> >
> >    <xsl:if test='name()=$columnName'>
> >       <xsl:value-of select=current() />
> >    </xsl:if>
> >  </xsl:for-each>
> > </xsl:for-each>
> >
> >
> > Am I not allowed to use ancestor from within Attribute
> > Context Node? If
> > not what will be the solution for the above?



> ==--==--==--==--==--==--==--==--==--==--==--==--==--==

S.Ramaswamy
Matrix Infotech Syndicate
D-7, Poorti, Vikaspuri, New Delhi, 110018, India
PHONE:    +91-11-5610050,   FAX: +91-11-5535103
WEB         http://MatrixInfotech.HyperMart.Net
==--==--==--==--==--==--==--==--==--==--==--==--==--==



 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.