XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Praneeth PVSubject: Need help to convert XMl -> HTML
Author: Praneeth PV
Date: 21 Apr 2007 08:53 AM
Hi there,
Am new to xsl. I am trying to convert an xml to html. The structure of my xml looks like this.
<lines>
<line>
<A>+</A>
<B>BLUE</B>
<C>DATA1</C>
</line>
<line>
<A>+</A>
<B>PINK</B>
<C>DATA2</C>
</line>
</lines>

I want my html output to look like this:

+DATA1
+DATA2

The color mentioned in <B> indicates the bgcolor, it is valid till the next <B> is encountered.

As mentioned earlier, am very new to xsl. I guess my XPATH expressions are not correct. My output looks like this:

+
DATA1
+
DATA2

I want all <line> elements to end with a newline, and all children in a line element should be on the same line.

Please help me out.

Thanks

Postnext
(Deleted User) Subject: Need help to convert XMl -> HTML
Author: (Deleted User)
Date: 23 Apr 2007 12:54 PM
Hi Praneeth,
you need to give us more informations:
- which version of Stylus Studio are you using?
- which XSLT processor are you using?
- is the XSLT generating TEXT or HTML?
- could you post the fragment of the XSLT that generates the result you posted?

Thanks,
Alberto

Postnext
Praneeth PVSubject: Need help to convert XMl -> HTML
Author: Praneeth PV
Date: 24 Apr 2007 09:07 AM
Hi Alberto,

Here is the information you asked for.
This is my xml.

<?xml version="1.0" encoding="UTF-8"?>
<lines>
<line>
<A>+</A>
<B>BLUE</B>
<C>DATA1</C>
</line>
<line>
<A>+</A>
<B>PINK</B>
<C>DATA2</C>
</line>
</lines>

This is the xsl I have written:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<html>
<head><title>MyHTML</title></head>
<body>
<pre>
<xsl:for-each select="lines">
<xsl:for-each select="child::line">

<xsl:choose>
<xsl:when test="A">
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:when test="B">
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:when test="C">
<xsl:apply-templates select="."/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<br></br>
</xsl:for-each>
</pre>
</body>
</html>
</xsl:template>
<xsl:template match="A">
<xsl:value-of select="."></xsl:value-of>
</xsl:template>
<xsl:template match="C">
<xsl:value-of select="."></xsl:value-of>
</xsl:template>
</xsl:stylesheet>

Now, if you notice, I haven't defined a template to handle <B>. But my output when i used XMLSpy 2004 Enterprise Edition is:
+BLUEDATA1+PINKDATA2

When i used IntelliJ's built-in XSLT processor, the same xsl on the same xml produced this output:
+
BLUE
DATA1

+
PINK
DATA2

I am not sure how 'BLUE' and 'PINK' are seen in the html output in the first place.
Please help me. I hope I have provided all information this time.

Thanks,
Praneeth

Posttop
(Deleted User) Subject: Need help to convert XMl -> HTML
Author: (Deleted User)
Date: 24 Apr 2007 09:26 AM
Hi Praneeth,
even if you didn't define a template for B, XSLT defines a default template that prints any text node (including the text nodes that makes up the indentation of the XSLT stylesheet itself).
I would suggest you to download a trial copy of Stylus Studio and use its debugger to see how a processor generates its output.

Hope this helps,
Alberto

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.