We help IT Professionals succeed at work.
Get Started

Need to add an attribute to an XML element, using XSLT

fsyed
fsyed asked
on
304 Views
Last Modified: 2013-11-18
Dear fellow developers:

I have an XML document that has the structure listed below.  Each <collection>  element has several <volume> elements, each <volume> element contains several <book> elements, each <book> element contains several <chapter> elements, and each <chapter> element contains several <quote> elements.  What I would like to do is include an "id" attribute at the end of the attribute list for the <quote> element.  For now, I'd like to leave the value of the "id" attribute to be 0 (i.e. id="0").   How would I do this?  

Thanks in advance to all who reply.

<?xml version="1.0" encoding="UTF-8"?>
<collection name="collection title">
   <volume number="1">
      <book number="1" title="book title">
         <chapter number="1" title="chapter title">
             <quote number="1" grade="authentic" reference="Volume 1, Book 1, Chapter 1, Number 1">
               <meta>
                  <description></description>
               </meta>
               <narrator>John Doe</narrator>
               <matn>
                  <matn-text></matn-text>
                  <matn-footnote></matn-footnote>
               </matn>
               <link>
                  <key></key>
               </link>
            </quote>
            ...
          </chapter>
          <chapter>
          ...
          </chapter>
          ...
        </book>
        ...
     </volume>
     ...
   </chapter>

Open in new window

Comment
Watch Question
Information Architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE