xsl-list
[Top] [All Lists]

RE: [xsl] Creating multiple nodes from a source node data

2009-09-18 04:12:14
I'm trying to find a way to transform an XML element text and 
form elements using that text.

I/P XML

<info>
        <p> Name:</p>
         </nl>emp1
         <p>Emp No:</P>
         </nl>1234
         <p>address:</p>
         </nl>address1
         </nl>---------------
         <p>Name:</p>
         </nl>emp2
         <p>Emp No:</p>
         </nl>12345
         <p>address:</p>
         </nl>address2
</info>

I hope that's not your input, because it's not XML. But assuming that's just
carelessness, the way to solve this kind of problem in XSLT 2.0 is with

<xsl:template match="info">
  <xsl:for-each-group select="node()"
group-starting-with="text()[.='------------']">
    <emp>
      <xsl:apply-templates select="current-group()"/>
    </emp>
  </
</

Regards,

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



Desired O/P XML

<emp>
         <empinfo>
                       <empname>emp1</empname>
                       <empno>1234</empno>
                       </empinfo>
        <empaddress>
                       <address>address1</address>
        </empaddress>
</emp>
<emp>
         <empinfo>
                      <empname>emp2</empname>
                      <empno>12345</empno>
                      </empinfo>
         <empaddress>
                      <address>address2</address>
         </empaddress>
</emp>

In input XML ------------ is a delimiter which signifies the 
starting of new emp info.
I'm using XSL version 2.0, can the gurus please suggest me a 
way to achieve this.

--
Regards,
Byran

--~------------------------------------------------------------------
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>