This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: XSL for element containing mixed content.


Sandeep Deshpande <san25872@yahoo.com> wrote:
> How do I write XSL for following section of XML file.
> 
> <directory>
> Hi I am in a directory.
> <subdirectory>
> Hi I am in a subdirectory.
> <file>
> Hi I am in file.
> </file>
> </subdirectory>
> </Directory>
> 
> In the above case if I make a template for 'directory'
> then I can write '<xsl:value-of select ".">',

This construct is defined to return all text in the node
and all subnodes, as you has noted.

It would be easier and more robust to change your XML
structure, for example:
  <directory>
    <text>Hi I am in a directory.</text>
    <subdirectory>
      <text>Hi I am in a subdirectory.</text>
      <file>
        <text>Hi I am in file.</text>
    </file>
   </subdirectory>
  </directory>

Of yourse, if you want to store the name instead of arbitrary
text, it'd be more intuitive to use <name> instead of <text>.

HTH
J.Pietschmann

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]