xsl-list
[Top] [All Lists]

RE: [xsl] Generically Finding Parent Elements

2008-05-05 16:03:48
You're not explaining yourself well. You've shown some source XML (good) and
have then said that the actual XML might be completely different (so why
show it?).  Then you say:

I need to be able to pull the parent node tree into a variable so I can
then loop over them. 

Parent of what? What is a "parent node tree"? What does "them" refer to (I
can't find a plural noun)? Why do you want to loop over "them"? Why do you
imagine that pulling it/them into a variable will help? And last but not
least, what output are you trying to produce?

Perhaps (guessing wildly) you just want

<xsl:for-each select="ancestor::*">

Michael Kay
http://www.saxonica.com/



-----Original Message-----
From: Tim Dexter [mailto:timothy(_dot_)dexter(_at_)gmail(_dot_)com] 
Sent: 05 May 2008 21:25
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Generically Finding Parent Elements

Hi All

Im struggling with a problem. Assume I have the following XML

<?xml version="1.0"?>
<ROOT>
 <DEPTS>
  <DEPT>
   <DEPTNO>10</DEPTNO>
   <DEPTNAME>Accounting</DEPTNAME>
   <EMPLOYEES>
    <EMPLOYEE>
     <EMPNUM>10001</EMPNUM>
     <EMPNAME>Jo Bloggs</EMPNAME>
     <SALARY>100000</SALARY>
    </EMPLOYEE>
    <EMPLOYEE>
     <EMPNUM>10002</EMPNUM>
     <EMPNAME>Jo Smother</EMPNAME>
     <SALARY>220000</SALARY>
    </EMPLOYEE>
    <EMPLOYEE>
     <EMPNUM>10003</EMPNUM>
     <EMPNAME>James Dean</EMPNAME>
     <SALARY>1000</SALARY>
    </EMPLOYEE>
   </EMPLOYEES>
  </DEPT>
  <DEPT>
   <DEPTNO>20</DEPTNO>
   <DEPTNAME>Shipping</DEPTNAME>
   <EMPLOYEES>
    <EMPLOYEE>
     <EMPNUM>20001</EMPNUM>
     <EMPNAME>Dave Gibbons</EMPNAME>
     <SALARY>100000</SALARY>
    </EMPLOYEE>
    <EMPLOYEE>
     <EMPNUM>20002</EMPNUM>
     <EMPNAME>John Fisher</EMPNAME>
     <SALARY>220000</SALARY>
    </EMPLOYEE>
    <EMPLOYEE>
     <EMPNUM>20003</EMPNUM>
     <EMPNAME>Marti Johnson</EMPNAME>
     <SALARY>1000</SALARY>
    </EMPLOYEE>
   </EMPLOYEES>
  </DEPT>
 </DEPTS>
</ROOT>

This is just a sample XML the XSL template needs to handle 
any number of levels in the XML - the only known element is 
the ROOT name. I need to be able to pull the parent node tree 
into a variable so I can then loop over them. The looping I 
can handle, any help on grabbing the parent element names in 
a tree gratefully received.

Thanks

Tim

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>