Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie question on xml-xsl for plain text: non db 1

Status
Not open for further replies.

raghu3

Programmer
Dec 19, 2005
96
US
I have plain text XML file. This was html that I converted to XML for easy editing.
I had a CSS style sheet that I need to convert to xsl as css is not being read by ASP.NET. Eg:
Title
Main heading
text

sub heading
text

sub heading2
text

On the CSS I had a style sheet for each type and this got applied as and when the text came up.

I built a xls using foreach and only 1st item shows up.
I tried apply-template, nothing appears. I am sure I am missing something. Can some body suggest a simple, non-db xls style sheet.
Thanks a lot


 
hi, can u post your xsl? would be easy to help u fix the problem :)
 
<?xml version="1.0" encoding="iso-8859-1"?>
<html xsl:version="1.0" xmlns:xsl=" xmlns="
<body style="font-family:Arial,helvetica,sans-serif">

<xsl:for-each select="policy">
<div style="font-family:Arial,helvetica,
sans-serif;font-size:18px">
<span style="font-weight:bold;color:black">
<xsl:value-of select="policyname"/></span>
</div>

<div style="font-family:Arial,helvetica,
sans-serif;font-size:16px">
<span style="font-weight:bold;color:black">
<xsl:value-of select="mainhead"/></span>
</div>

<div style="font-family:Arial,helvetica,
sans-serif;font-size:12px">
<span style="font-weight:;color:black">
<xsl:value-of select="mhtext"/></span>
</div>

<div style="font-family:Arial,helvetica,
sans-serif;font-size:14px">
<span style="font-weight:bold;color:black">
<xsl:value-of select="subhead"/></span>
</div>

<div style="font-family:Arial,helvetica,
sans-serif;font-size:10px">
<span style="font-weight:;color:black">
<xsl:value-of select="shtext"/></span>
</div>

<div style="font-family:Arial,helvetica,
sans-serif;font-size:12px">
<span style="font-weight:bold;color:black">
<xsl:value-of select="sb2"/></span>
</div>

</xsl:for-each>

</body>
</html>

My XML is like
<policyname> </policyname>
<mainhead> </mainhead>
<mhtext> </mhtext>
.
.
.

This is just a policy so not necessary every mainhead should have subhead ...
I looked a a basic XSL tutorial and created the above. All I need is text formatting.
Thanks
 
and you have a <policy> tag for each entry like,
<policy>
<policyname> </policyname>
<mainhead> </mainhead>
<mhtext> </mhtext>
</policy>
is that the correct tree?
 
if you are trying to loop using the main tag u will always get one result, policy is the top level tag. if for example u want to have different policyname then something like this would make more sense,

<policy>
<record>
<policyname> </policyname>
<mainhead> </mainhead>
<mhtext> </mhtext>
</record>
<record>
<policyname> </policyname>
<mainhead> </mainhead>
<mhtext> </mhtext>
</record>
...
</policy>

then your foreach would be for record. Just used that name as an example of course. I am understanding your xml correctly or u dont have several policyname?
 
Thanks sonya9879, thats what I thought.
Also not all <record> will have the <subhead> <sb2>.
I guess the foreach look will apply the style if It finds it.

Will re-do the XML and see.

raghu1
 
good luck, and have patience using xsl :), it can get pretty complex :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top