[xsl] node list problem

Subject: [xsl] node list problem
From: "Elaine STEWART" <ELAINEST@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Sep 2005 09:32:02 +0100
I have a xml file structure as follows...

<JOB_APPLICATIONS_FROM_WEB>
   <application>
      <vacancy_id>AN123/05</vacancy_id>
      <applicant_id>WA00315</applicant_id>
      <source_name>W</source_name>
      <acc_employee>F</acc_employee>
      <initials>A</initials>
      <surname>Yurkov</surname>
        ....
      <equal_opportunities>
         <eq_opps>
            <date_of_birth_DD>21</date_of_birth_DD>
            <date_of_birth_MM>Jun</date_of_birth_MM>
            <date_of_birth_YYYY>1976</date_of_birth_YYYY>
               ...
         </eq_opps>
      </equal_opportunities>
      <references>
         <reference>
            <ref_title>MRS</ref_title>
            <ref_forename>Jenny</ref_forename>
            <ref_surname>McHugh</ref_surname>
            <ref_check>F</ref_check>
         </reference>
      </references>
   </application>
   <application>
      <vacancy_id>AC358/05</vacancy_id>
      <applicant_id>WA08340</applicant_id>
      <source_name>W</source_name>
      <acc_employee>F</acc_employee>
      ....
</JOB_APPLICATIONS_FROM_WEB

I want to change the above structure to look like the following...

<JOB_APPLICATIONS_FROM_WEB>
   <application>
      <vacancy_id>AN123/05</vacancy_id>
      <applicant_id>WA00315</applicant_id>
      <source_name>W</source_name>
      <acc_employee>F</acc_employee>
      <initials>A</initials>
      <surname>Yurkov</surname>
        ....
      <equal_opportunities>
         <eq_opps>
            <vacancy_id>AN123/05</vacancy_id>
            <applicant_id>WA00315</applicant_id>
            <date_of_birth_DD>21</date_of_birth_DD>
            <date_of_birth_MM>Jun</date_of_birth_MM>
            <date_of_birth_YYYY>1976</date_of_birth_YYYY>
               ...
         </eq_opps>
      </equal_opportunities>
      <references>
         <reference>
            <vacancy_id>AN123/05</vacancy_id>
            <applicant_id>WA00315</applicant_id>
            <ref_title>MRS</ref_title>
            <ref_forename>Jenny</ref_forename>
            <ref_surname>McHugh</ref_surname>
            <ref_check>F</ref_check>
         </reference>
      </references>
   </application>
   <application>
      <vacancy_id>AC358/05</vacancy_id>
      <applicant_id>WA08340</applicant_id>
      <source_name>W</source_name>
      <acc_employee>F</acc_employee>
      ....
</JOB_APPLICATIONS_FROM_WEB

I want to take the vacancy_id and applicant_id fields and insert them
again under eq_opps and reference.

I have tried various things but always get the same value from the very
first record.

I've tried doing...

<xsl:variable name="v_vid" select="//application/@vacancy_id"/>

to give me a node list, but I'm not sure how to iterate around them.

Another option...

<xsl:template match="eq_opps">
      <xsl:copy>
            <vacancy_id><xsl:value-of
select="//application/@vacancy_id"/></vacancy_id>


I'm using XSLT version1.

The following code I'm using in Oracle 8 and works ok but does not work
in Oracle 9.

    <xsl:template match="application">
      <xsl:variable name="vid" select="@vacancy_id"/>
      <xsl:variable name="appid" select="@applicant_id"/>
        <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
  </xsl:template>
   <xsl:template match="eq_opps">
     <xsl:copy>
       <vacancy_id><xsl:value-of select="$vid"/></vacancy_id>
       <applicant_id><xsl:value-of select="$appid"/></applicant_id>
         <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
   </xsl:template>


Any suggestions?

   


Elaine Stewart
System Analyst
Finance & ICT Services
Telephone: 01224 523608

Elaine Stewart
System Analyst
Finance & ICT Services
Telephone: 01224 523608


IMPORTANT NOTICE: This e-mail (including any attachment to it) is confidential, protected by copyright and may be privileged.  The information contained in it should be used for its intended purposes only.  If you receive this e-mail in error, notify the sender by reply e-mail, delete the received e-mail and do not make use of, disclose or copy it. Whilst we take reasonable precautions to ensure that our emails are free from viruses, we cannot be responsible for any viruses transmitted with this e-mail and recommend that you subject any incoming e-mail to your own virus checking procedures.  Unless related to Council business, the opinions expressed in this e-mail are those of the sender and they do not necessarily constitute those of Aberdeen City Council. Unless we expressly say otherwise in this e-mail or its attachments, neither this e-mail nor its attachments create, form part of or vary any contractual or unilateral obligation. 
Aberdeen City Council's incoming and outgoing e-mail is subject to regular monitoring.

Current Thread