xsl-list
[Top] [All Lists]

[xsl] Matching or selecting template problem

2009-01-15 10:34:38
There are some advanced aspects of XSLT that I just don't seem to "get." I'm really struggling with what some of you may consider a simple problem. I can seem to find a way to match part of the following instance. I've tested the following XPath statements with Oxygen and get the results I want. Somehow I can't seem to translate that into a template match.

Wendell, you've been a great help to my previous questions, I hope you're not disappointed in me as a former student. Unfortunately, a full year has passed since a requirement has developed for me to put the XSLT coursework into a real world exercise.

My problem: I need to match all the following sibling elements of the last <section> (in this case two <p> element and a <ul>) and create a new sibling <section> with the current following siblings as children of the new <section>.

I have tried:

conbody/section[last()]/following-sibling::* (XPath returns the correct result, but not valid as a template match)

<xsl:template match="//conbody/section[last()]/p"/> Again, the XPath test gives me the expected result, but doesn't seem to match in a tempate
 <xsl:template match="//conbody/section[last()]/ul"/> Same as previous.

I think I can create a template to match the following siblings of the last <section>, I can use a For Each to create the new section? Am I on the right track ? I'm unclear as to how to create new high level elements in which I need to nest EXISTING elements.

I appreciate any solutions, but I would also like to understand the parts of this I seem to "get."

Current content:*
*
<?xml version="1.0" encoding="UTF-8"?>
<concept  class="- topic/topic concept/concept">
   <title>TITLE</title>
   <prolog class="- topic/prolog "/>
   <conbody class="- topic/body concept/conbody">
       <section><title>TITLE</title></section>
       <section><title>TITLE</title></section>
       <section><title>TITLE</title></section>
       <p>TEXT</p>
       <p>TEXT</p>
       <ul>
           <li>
               <p>
                   TEXT
               </p>
           </li>
           <li>
               <p>
                   <xref/>
               </p>
           </li>
       </ul>
   </conbody>
</concept>

Desired Result:

<?xml version="1.0" encoding="UTF-8"?>
<concept class="- topic/topic concept/concept">
   <title>TITLE</title>
   <prolog class="- topic/prolog "/>
   <conbody class="- topic/body concept/conbody">
       <section><title>TITLE</title></section>
       <section><title>TITLE</title></section>
       <section><title>TITLE</title></section>
      <section>
       <p>TEXT</p>
       <p>TEXT</p>
       <ul>
           <li>
               <p>
                   TEXT
               </p>
           </li>
           <li>
               <p>
                   <xref/>
               </p>
           </li>
       </ul>
      </section>
   </conbody>
</concept>

Charles Flanders
cflanders(_at_)vasont(_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>