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: Fri, 28 Mar 2008 06:22:02 -0700,    group: microsoft.public.xml        back       


How to format an embedded tag's content   
Hi all,

I have an xml section like this:

...
<summary>
 this year we earn <benefit>5,000</benefit> dollars,....


</summary>
...
in the declaration part 

<!ELEMENT summary ANY >

I am using XSLT to output the xml file to HTML format, how can I output the 
whole summary section and only make the 5,000 green color.

Clara
-- 
thank you so much for your help
date: Fri, 28 Mar 2008 06:22:02 -0700   author:   clara

Re: How to format an embedded tag's content   
clara wrote:

> I have an xml section like this:
> 
> ...
> <summary>
>  this year we earn <benefit>5,000</benefit> dollars,....
> 
> 
> </summary>
> ...
> in the declaration part 
> 
> <!ELEMENT summary ANY >
> 
> I am using XSLT to output the xml file to HTML format, how can I output the 
> whole summary section and only make the 5,000 green color.

   <xsl:template match="summary">
     <p><xsl:apply-templates/></p>
   </xsl:template>

   <xsl:template match="benefit">
     <span style="color: green;">
       <xsl:apply-templates/>
     </span>
   </xsl:template>

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Fri, 28 Mar 2008 14:30:31 +0100   author:   Martin Honnen

Re: How to format an embedded tag's content   
Hi Martin,

I usually use <xsl:value-of select="."> to output a tag's content, what' s 
the different between<xsl:value-of select="."> and<xsl:apply-templates />?

Clara
-- 
thank you so much for your help


"Martin Honnen" wrote:

> clara wrote:
> 
> > I have an xml section like this:
> > 
> > ...
> > <summary>
> >  this year we earn <benefit>5,000</benefit> dollars,....
> > 
> > 
> > </summary>
> > ...
> > in the declaration part 
> > 
> > <!ELEMENT summary ANY >
> > 
> > I am using XSLT to output the xml file to HTML format, how can I output the 
> > whole summary section and only make the 5,000 green color.
> 
>    <xsl:template match="summary">
>      <p><xsl:apply-templates/></p>
>    </xsl:template>
> 
>    <xsl:template match="benefit">
>      <span style="color: green;">
>        <xsl:apply-templates/>
>      </span>
>    </xsl:template>
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
>
date: Fri, 28 Mar 2008 07:01:01 -0700   author:   clara

Re: How to format an embedded tag's content   
clara wrote:

> I usually use <xsl:value-of select="."> to output a tag's content, what' s 
> the different between<xsl:value-of select="."> and<xsl:apply-templates />?

<xsl:value-of select="."/> outputs the string value of the context node 
while <xsl:apply-templates/> processes all child nodes, making sure that 
any child elements can be processed by matching templates.
So with your original markup and
   <xsl:template match="summary">
     <xsl:value-of select="."/>
   </xsl:template>
you get a text node with the text "this year we earn 5,000 dollars,...." 
while with my suggestion

   <xsl:template match="summary">
     <p><xsl:apply-templates/></p>
   </xsl:template>

   <xsl:template match="benefit">
     <span style="color: green;">
       <xsl:apply-templates/>
     </span>
   </xsl:template>

you get
   <p>this year we earn <span style="color: green;">5,000</span> 
dollars,....</p>
a 'p' element with three child nodes, a text node, a 'span' element with 
the style you want and a text node.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Fri, 28 Mar 2008 15:15:32 +0100   author:   Martin Honnen

Google
 
Web ureader.com


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