Re: [xsl] XSL for element containing mixed content.

Subject: Re: [xsl] XSL for element containing mixed content.
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Fri, 07 Sep 2001 13:44:22 +0200
Sandeep Deshpande <san25872@xxxxxxxxx> 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


Current Thread