Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Sun, 20 Jul 2008 01:45:43 -0700 (PDT),    group: microsoft.public.xsl        back       


simple xsl question   
Hi,

I'm learning xsl and am encountering an unexpected  result with the
xml / xsl below

The xsl result includes text from the printsettings nodes:  "1none",
and since this was not included in the select attribute.

It's strange that the unspecified node is the first node of the
document.  I've simplified the xml document to remove other nodes, but
when those nodes were present it was still only the first node that
had it's text printed out.

If you have any idea why the text of the printsettings nodes is being
printed I'd appreciate hearing the explanation.

I'm using Microsofts XMLNotepad to view the output

Thank you,

Rod


<?xml version="1.0" encoding="utf-8"?>
<template>

  <printsettings>
    <orientation>1</orientation>
    <header>none</header>
  </printsettings>

  <columns>

	<colrange name="C1">
      <coldimspecs>
        <coldimspec >
          <memberspecs>
            <memberspec />
          </memberspecs>
        </coldimspec>
        <coldimspec dimensionname="Scenario" >
          <memberspecs>
            <memberspec memberkey="" />
          </memberspecs>
        </coldimspec>
      </coldimspecs>
    </colrange>

    <colrange name="C2">
      <coldimspecs>
        <coldimspec >
          <memberspecs>
            <memberspec />
          </memberspecs>
        </coldimspec>
        <coldimspec dimensionname="Scenario" >
          <memberspecs>
            <memberspec memberkey="" />
          </memberspecs>
        </coldimspec>
      </coldimspecs>
    </colrange>

  </columns>

</template>






<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">

<xsl:template match="/">
<HTML>
<BODY>
    <xsl:apply-templates/>
</BODY>
</HTML>
</xsl:template>


<xsl:template match="columns/colrange">
<TABLE BORDER="1"  width="40%" >
<TR>

	<xsl:value-of select="local-name()"/>
	<xsl:text>:  </xsl:text>		<xsl:value-of select="@name"/>
	<xsl:text>   </xsl:text>		<xsl:value-of select="@description"/>

        <xsl:for-each select="*/*/*/*">
          <TD>
              <xsl:value-of select="local-name()"/>
          </TD>
        </xsl:for-each>

</TR>

</TABLE>

</xsl:template>



</xsl:stylesheet>
date: Sun, 20 Jul 2008 01:45:43 -0700 (PDT)   author:   vanSkier

Re: simple xsl question   
vanSkier wrote:

> The xsl result includes text from the printsettings nodes:  "1none",
> and since this was not included in the select attribute.

> <xsl:template match="/">
> <HTML>
> <BODY>
>     <xsl:apply-templates/>


Here you process the child nodes of the root node so in your sample XML 
then 'template' element is processed by a matching template. As you have 
not provided one yourself the default template is used which processes 
all child nodes of the context node, in that case the 'printsettings' 
element and the 'columns' element. As you have not provided a matching 
template for 'printsettings' yourself the default tempate is used and 
that way, you end up with the text contents of child elements output to 
the result tree.
To fix that, use
       <xsl:apply-templates select="template/columns/colrange"/>
above, instead of the <xsl:apply-templates/> that you have.




-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Sun, 20 Jul 2008 13:08:23 +0200   author:   Martin Honnen

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us