RE: Re: [xsl] formatting issues

Subject: RE: Re: [xsl] formatting issues
From: ms <mina_hurray@xxxxxxxxx>
Date: Thu, 2 Nov 2006 06:33:02 -0800 (PST)
Hello:

Thank you all for taking time to go through my
question. 

Let me try to explain this. 

I have an input file:

<states>
 <state>
<sym>R<sym>
<Val1>text<Val1>
<Val2>text<Val2>
<Val3>text<Val3>
<Val4>text<Val4>
<state>
</states>

Now there can be any number of "state" child elements
under "states". The children of "state" are Val1,
Val2, Val3, Val4. So hetting these to display
correctly on the XSLT is not an issue.

Next, we come to the <xsl:apply-templates
select="server/getinfo.dox.../>

This server call returns data in XML format which is:

<results>

<data>
<Val5>something</Val5>
<Val6>something</Val6>
<Val7>something</Val7>
<Val8>P</Val8>
</data>

<data>
<Val5>something</Val5>
<Val6>something</Val6>
<Val7>something</Val7>
<Val8>P</Val8>
</data>

</results>

<data> can be any number inside <results>

The output should be like this. Consider the first
line the headers of the table:

VAL1 VAL2 VAL3 VAL4 VAL5 VAL6 VAL7 VAL8

Text

--- cknell@xxxxxxxxxx wrote:

> I'll try to help, but first I need the answers to
> some questions.
> 
> The first template matches the element "states"
> ===========================
> <xsl:template match="states">
>   <br/>
>   <xsl:if test="//state/sym='R'">
>  ... content omitted for clarity ...
> </xsl:template>
> ===========================
> 
> In your source XML document, is "states" the parent
> of all "state" elements, or do some "state" elements
> have "state" child elements?
> 
> 
> Further along in this template you have this:
> ===========================
> <xsl:for-each select="//state">
> ===========================
> 
> Unless you are planning to sort the elements, you
> probably don't need xsl:for-each, just use
> xsl:apply-templates.
> 
> Further along still you have this:
> ===========================
> <td><xsl:choose>xsl:value-of select="Val3"/></td>
> ===========================
> 
> Why do you have an opening xsl:choose without a
> closing tag and no xsl:when or xsl:otherwise within?
> 
> Still further along you have this:
> ===========================
> <xsl:apply-templates
>
select="document(concat($server,'/getinfo.dox?...........)"/>
> ===========================
> 
> Just what is it you are trying to get by
> concatenating the value of the variable or paramater
> $server with the string "'/getinfo.dox?..........."?
> 
> These problems aside, if your real XSLT works at all
> then it must be legal XML, which your sample is
> clearly not. I suspect your problem lies in these
> templates:
> 
> <xsl:template match="data/Val5">
>   <td><xsl:value-of select="."/></td>
> </xsl:template>
> 
> <xsl:template match="data/Val6">
>   <td><xsl:value-of select="node()"/></td>
> </xsl:template>
> 
> <xsl:template match="data/Val7">
>   <td><xsl:value-of select="node()"/></td>
> </xsl:template>
> 
> <xsl:template match="data/Val8">
>   <td><xsl:value-of select="node()"/></td>
> </xsl:template>
> 
> If the root element of the document you are getting
> with 
> <xsl:apply-templates
>
select="document(concat($server,'/getinfo.dox?...........)"/>
> is "data", then you have omitted the document root
> from the "match" attribute.
> 
> The correct XPath for these would begin with "/", as
> in match="/data/Val8".
> -- 
> Charles Knell
> cknell@xxxxxxxxxx - email
> 
> 
> 
> -----Original Message-----
> From:     ms <mina_hurray@xxxxxxxxx>
> Sent:     Wed, 1 Nov 2006 12:45:41 -0800 (PST)
> To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Re: [xsl] formatting issues
> 
> Hi:
> 
> Can someone please reply to this ? I have been
> pretyt
> frustrated with this problem and would really
> appreciate if anyone can help.
> 
> --- ms <mina_hurray@xxxxxxxxx> wrote:
> 
> > I have tried everything possible and have failed
> to
> > format this XML.
> > 
> > My XSLT looks like this:
> > 
> > <xsl:template match="states">
> > 		<br/>
> > 		<xsl:if test="//state/sym='R'">
> > 			<table width="100%">
> > 				<tr>
> > 					<td colspan="8">
> > 						<b>STATES: </b>
> > 					</td>
> > 				</tr>
> > 				<tr>
> > 					<td width="9%">
> > 						<u>Val1</u>
> > 					</td>
> > 					<td width="15%">
> > 						<u>Val2</u>
> > 					</td>
> > 					<td width="7%">
> > 						<u>Val3</u>
> > 					</td>
> > 					<td width="7%">
> > 						<u>Val4</u>
> > 					</td>
> > 					<td width="9%">
> > 						<u>Val5</u>
> > 					</td>
> > 					<td width="21%">
> > 						<u>Val6</u>
> > 					</td>
> > 					<td width="15%">
> > 						<u>Val7</u>
> > 					</td>
> > 					<td width="7%">
> > 						<u>Val8</u>
> > 					</td>
> > 				</tr>
> > 				<xsl:for-each select="//state">
> > 					<xsl:choose>
> > 						<xsl:when test="sym='R'">
> > 							<tr>
> > 								<td>
> > 									<xsl:value-of select="Val1"/>
> > 								</td>
> > 								<td>
> > 									<xsl:value-of select="Val2"/>
> > 								</td>
> > 								<td>
> > 									<xsl:choose>
> > 									
> > 											<xsl:value-of select="Val3"/>
> > 								
> > 								</td>
> > 								<td>
> > 									<xsl:value-of select="Val4"/>
> > 								</td>
> > 								<xsl:variable name="v1">
> > 									<xsl:value-of select="Val1"/>
> > 								</xsl:variable>
> > 								<xsl:variable name="v2">
> > 									<xsl:value-of select="Val2"/>
> > 								</xsl:variable>
> > 						
> > 								
> > 								<xsl:apply-templates
> >
>
select="document(concat($server,'/getinfo.dox?...........)"/>
> > 							</tr>
> > 						</xsl:when>
> > 					</xsl:choose>
> > 				</xsl:for-each>
> > 			</table>
> > 		</xsl:if>
> > 	</xsl:template>
> > 	<xsl:template match="results">
> > 		<tr>
> > 			<xsl:apply-templates/>
> > 		</tr>
> > 	</xsl:template>
> > 	<xsl:template match="data">
> > 		<xsl:apply-templates/>
> > 	</xsl:template>
> > 	<xsl:template match="data/Val5">
> > 		<td>
> > 			<xsl:value-of select="."/>
> > 		</td>
> > 	</xsl:template>
> > 	<xsl:template match="data/Val6">
> > 		<td>
> > 			<xsl:value-of select="node()"/>
> > 		</td>
> > 	</xsl:template>
> > 	<xsl:template match="data/Val7">
> > 		<td>
> > 			<xsl:value-of select="node()"/>
> > 		</td>
> > 	</xsl:template>
> > 	<xsl:template match="data/Val8">
> > 		<td>
> > 			<xsl:value-of select="node()"/>
> > 		</td>
> > 	</xsl:template>
> 
=== message truncated ===



 
____________________________________________________________________________________
Access over 1 million songs - Yahoo! Music Unlimited 
(http://music.yahoo.com/unlimited)

Current Thread
  • Re: [xsl] formatting issues, (continued)
      • Abel Braaksma - Wed, 01 Nov 2006 22:26:43 +0100
      • Michael Kay - Wed, 1 Nov 2006 21:55:25 -0000
        • ms - Thu, 2 Nov 2006 06:37:22 -0800 (PST)
    • cknell - Wed, 01 Nov 2006 16:54:18 -0500
      • ms - Thu, 2 Nov 2006 06:33:02 -0800 (PST) <=
      • ms - Thu, 2 Nov 2006 06:35:51 -0800 (PST)
    • cknell - Thu, 02 Nov 2006 10:18:25 -0500
    • ms - Thu, 2 Nov 2006 08:43:32 -0800 (PST)
    • cknell - Thu, 02 Nov 2006 12:30:23 -0500