xsl-list
[Top] [All Lists]

Re: [xsl] Processing on both a document list and referenced documents

2008-03-12 05:05:45
Hi Brad, everyone.

Here's what worked for me:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
        <xsl:output method="html" indent="yes"/>
        <xsl:template match="hdlg:filesystem"
xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>
                <html>
                        <body>
                                <ul>
                                        <xsl:for-each select="hdlg:folder"
xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>
                                                <li>
                                                        <xsl:value-of 
select="@url"/>
                                                        <ul>
                                                                <xsl:for-each 
select="document(hdlg:file/@url)"
xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>
                                                                        <ul>
                                                                                
<xsl:for-each select="topic">
                                                                                
        <li>
                                                                                
                <xsl:value-of select="title"/>
                                                                                
                <ul>
                                                                                
                        <xsl:for-each select="topic">
                                                                                
                                <li>
                                                                                
                                        <xsl:value-of select="title"/>
                                                                                
                                        <ul>
                                                                                
                                                <xsl:for-each select="topic">
                                                                                
                                                        <li>
                                                                                
                                                                <xsl:value-of 
select="title"/>
                                                                                
                                                        </li>
                                                                                
                                                </xsl:for-each>
                                                                                
                                        </ul>
                                                                                
                                </li>
                                                                                
                        </xsl:for-each>
                                                                                
                </ul>
                                                                                
        </li>
                                                                                
</xsl:for-each>
                                                                        </ul>
                                                                </xsl:for-each>
                                                        </ul>
                                                </li>
                                        </xsl:for-each>
                                </ul>
                        </body>
                </html>
        </xsl:template>
</xsl:stylesheet>


This XSL produced the output I described in my original email.


<html>
 <body>
    <ul>

       <!-- The following information comes from files2.xml -->

       <li xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>file:/C:/folder1/>
       <li xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>file:/C:/folder2>
          <ul>
             <!-- The following information comes from the referenced
DITA files -->
             <li>topicA
                <ul>
                   <li>topicB</li>
                   <li>topicC</li>
                </ul>
             </li>
          </ul>
          <ul>
             ..
          </ul>
       <!-- The following information comes from files2.xml -->
       <li xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>file:/C:/folder3>
       ..
    </ul>
  </body>
</html>

Thanks,
Mark


On Tue, Mar 11, 2008 at 9:00 PM, Mark Peters 
<flickrmeister(_at_)gmail(_dot_)com> wrote:
Hi Brad,

 I appreciate your efforts. I've studied the stylesheet you wrote, but
 haven't been able to parse it mentally. When I apply it against my
 sample files, the HTML body element is empty. I've tried passing the
 documents to the stylesheet as variables, but without success.

 The HDLG tool (http://hdlg.sourceforge.net/) produced an XML file
 containing the directory structure of my XML files. The file is named
 files2.xml in my original email. As you noticed the files referenced
 by files2.xml are DITA XML files containing nested topic elements.

 What I'm trying to do is produce an HTML listing of the folders and
 files in files2.xml, but with the topic titles from the referenced
 files appearing as sub-bulleted lists below each folder/file.

 For example:

 <html>
  <body>
     <ul>

        <!-- The following information comes from files2.xml -->

        <li 
xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>file:/C:/folder1/>
        <li xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>file:/C:/folder2>
           <ul>
              <!-- The following information comes from the referenced
 DITA files -->

              <li>topicA
                 <ul>
                    <li>topicB</li>
                    <li>topicC</li>
                 </ul>
              </li>
           </ul>
           <ul>
              ..
           </ul>
        <!-- The following information comes from files2.xml -->

        <li xmlns:hdlg="http://www.hdlg.info/XML/filesystem";>file:/C:/folder3>
        ..
     </ul>
   </body>
 </html>


 My current XSL transformation (provided in the original email) pulls
 each folder name from files2.xml using a for-each statement. When I
 try to retrieve the topic/title values for the files in each specific
 folder, the transformation instead retrieves the topic/title values
 for *all* of the files referenced in files2.xml.

 Thanks again,
 Mark


 On Tue, Mar 11, 2008 at 6:00 PM, Bjorndahl, Brad

<brad(_dot_)bjorndahl(_at_)thermofisher(_dot_)com> wrote:

Mark,
 >
 >  I'm still not sure I get all your requirements, but look at this to see 
if it handles the files the way you want.
 >  >

 Hoping this helps or at least gives you more options,
 >  Brad
 >
 >




 --



Mark Peters
 Senior Technical Writer
 Saba Software




-- 

Mark Peters
Senior Technical Writer
Saba Software

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