Advertisement

08.08.2006 at 11:19AM PDT, ID: 21947359
[x]
Attachment Details

Looping through xml file

Asked by fritz_the_blank in Extensible Markup Language (XML), Extensible HTML (XHTML)

Tags: through, xml, loop, asp, file

Thank you for reading my question.

I have the following xml and xsl files.

There are two things that I would like:

1) add the doc types or whatever I need to do so that it validates at http://validator.w3.org/
2) if the parameter being passed does not have sub elements (i.e. <xsl:if test="subheading1"> ) the page renders fine, otherwise, I get an error saying :

rror Type:
msxml3.dll (0x80004005)
The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

Here is the code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>
<xsl:param name="fname" select="'test'"/>
    <xsl:template match="/">
      <ul class="clsMainNav">
            <xsl:for-each select="/navigation/heading">
                <li>
                    <xsl:choose>
                        <xsl:when test="url=$fname">
                            <a href="{normalize-space(url)}"><img src="images/NavArrow.gif"  style="border: none; margin-left: 5px; valign: middle;" alt="-" /><xsl:value-of select="text"/></a>
                      <xsl:if test="subheading1">
                        <ul class="clsSubNav1">
                            <xsl:for-each select="subheading1">
                              <li>
                                  <xsl:choose>
                                    <xsl:when test="urlsub1= $fname">
                                        <a href="{normalize-space(urlsub1)}"><img src="images/NavArrow.gif"  style="border: none; margin-left: 5px; valign: middle;" alt="-" /><xsl:value-of select="textsub1"/></a>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <a href="{normalize-space(urlsub1)}"><img src="images/NavBlank.gif"  style="border: none; margin-left: 5px; valign: middle;" alt="-" /><xsl:value-of select="textsub1"/></a>
                                    </xsl:otherwise>
                                  </xsl:choose>
                              </li>
                            </xsl:for-each>
                        </ul>
                      </xsl:if>
                  </xsl:when>
                        <xsl:otherwise>
                            <a href="{normalize-space(url)}"><img src="images/NavBlank.gif"  style="border: none; margin-left: 5px; valign: middle;" alt="-" /><xsl:value-of select="text"/></a>
                        </xsl:otherwise>
                    </xsl:choose>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:template>
</xsl:stylesheet>



<?xml version="1.0" encoding="ISO-8859-1"?>
<navigation>
      <heading>
            <text>Home</text>
            <url>index.asp</url>
      </heading>
      <heading>
            <text>About Us</text>
            <url>pages/about.asp</url>
            <subheading1>
                  <textsub1>Mission Statement</textsub1>
                  <urlsub1>pages/missionstatement.asp</urlsub1>
            </subheading1>
            <subheading1>
                  <textsub1>By Laws</textsub1>
                  <urlsub1>pages/bylaws.asp</urlsub1>
            </subheading1>
      </heading>
      <heading>
            <text>Events</text>
            <url>pages/events.asp</url>
      </heading>
      <heading>
            <text>Forum</text>
            <url>pages/forum.asp</url>
      </heading>
      <heading>
            <text>Resources</text>
            <url>pages/resources.asp</url>
            <subheading1>
                  <textsub1>Medieval</textsub1>
                  <urlsub1>pages/medieval.asp</urlsub1>
            </subheading1>
            <subheading1>
                  <textsub1>Renaissance</textsub1>
                  <urlsub1>pages/renaissance.asp</urlsub1>
            </subheading1>
            <subheading1>
                  <textsub1>Baroque</textsub1>
                  <urlsub1>pages/baroque.asp</urlsub1>
            </subheading1>
            <subheading1>
                  <textsub1>18th Century</textsub1>
                  <urlsub1>pages/eighteenthcentury.asp</urlsub1>
            </subheading1>
            <subheading1>
                  <textsub1>19th Century</textsub1>
                  <urlsub1>pages/nineteenthcentury..asp</urlsub1>
            </subheading1>
      </heading>
      <heading>
            <text>Archives</text>
            <url>pages/archives.asp</url>
      </heading>
</navigation>

Thanks again,

FtBStart Free Trial
[+][-]08.08.2006 at 11:38AM PDT, ID: 17273618

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.08.2006 at 11:44AM PDT, ID: 17273673

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.08.2006 at 12:04PM PDT, ID: 17273846

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.08.2006 at 12:11PM PDT, ID: 17273892

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.08.2006 at 02:15PM PDT, ID: 17274831

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.08.2006 at 02:20PM PDT, ID: 17274851

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.08.2006 at 03:18PM PDT, ID: 17275200

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.08.2006 at 08:18PM PDT, ID: 17276394

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.09.2006 at 01:19AM PDT, ID: 17277216

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Extensible Markup Language (XML), Extensible HTML (XHTML)
Tags: through, xml, loop, asp, file
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.09.2006 at 09:05AM PDT, ID: 17280460

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.09.2006 at 09:10AM PDT, ID: 17280531

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2006 at 09:14AM PDT, ID: 17280564

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2006 at 09:27AM PDT, ID: 17280693

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.09.2006 at 09:50AM PDT, ID: 17280881

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32