• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

XML/XSL Transformation to HTML problem

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Friends,
Can anyone help me out with the following code in getting me the desired result
Following is an XML file:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="first.xsl"?>
<advertisement>
<text>
<headline>Welcome to <b>Northington</b> company</headline>
</text>
</advertisement>
and the XSL file first.xsl)
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/" >
<html>
<body>
<i>
<xsl:value-of select="advertisement/text/headline" />
</i>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

My question is how do I get Northington as bold with the para in italic and Northington embedded in it?

 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure I understand what you want right, but if you want
Welcome to Northington company
then your XSLT will look like this:
<?xml version='1.0'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/" >
<html>
<body>
<i><xsl:apply-templates select="advertisement/text/headline"/></i>
</body>
</html>
</xsl:template>
<xsl:template match="b">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Here instead of ouputting the content of headline element "as is", you apply templates to it.
 
Sumit Israni
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Mapraputa,
Man ,that was what I wanted .Should I thank you enough for it?
Thanks a million,
Regards
Sumit
 
Sumit Israni
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Mapraputa,
I tried the above solution to my file as is ..but it still doesnt work .Does it have anything to do with my browser.My browser version is Internet Explorer 5.0.Please guide me as soon as possible.Thanks again
Regards
 
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mapraputa,
I even tried it. But its not working.
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hm. So how exactly it is not working? Do you have any error message? Incorrect output? I put my example here: http://www.javaranch.com/xml/first.xml
and what I see (with IE5) when clicking on the link is
Welcome to Northington company
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A blank page comes up. No error message. Nothing is thr.
Even the link you have shown results in a blank page. I am using IE5.
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I see a blank page too with IE 5.5
In View/Source I can see the XML code
 
Sumit Israni
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Mapraputa,
I tried the link you gave but what I see is a blank page.Hope to receive your advice soon.Thanks a lot
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Sumit Israni
The namespace which u use i sold one i guess, try to use the new namespace
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
and try ro run the Mapraputa code,
it should work, i tried it out it worked,
i used xmlspy it worked for me,

 
Sumit Israni
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there Ravi,
Thanks for your reply .However the problem persists with Internet Explorer 5.0.And the namespace that I used in my program above is actually the one which Microsoft supports as per a book called Mastering XML.As of now the only solution I have available in achieving the desired result is via CSS. But about XSLT no comments!!I am confused
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it better now?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Friends,
Even I tried the link given by Mapraputa,but what I see is a blank page .But when I view the source of that page it shows the right thing.I'm facing the same problem and me too is confused.Is it a problem with my coding or IE or XSLT
Can anyone throw a light on this to get the solution.
Thanks.
Regards,
SHAILENDRA.
 
Sumit Israni
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Muhahahaha , Mapraputa you now have to reply to 4 persons in all
me,Parmeet,Terence and now Shailesh or should we hold Microsoft responsible for this mess??Microsoft certainly makes me go in loops with its product
By the way Mr.Ajit Kalambella's comments are wanting here!
 
Sumit Israni
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Shailendra there for spelling your name wrong! I think it must be the Microsoft effect that has taken over me which is why I am making spelling mistakes!!
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting.
I do not have a total solution, but believe this is related to MS/IE. I ran some experiments:
I also get a blank page when going to Map's example.
In the blank page, if you select 'View->Source', you see the original XML exactly.
I'm running '98, I/E 5.0, with Xerces 1.3.0 and Xalan 2 installed.

I cut+paste the XML and XSL files involved.
If I delete the stylesheet specification in the XML file and run a command line Xalan transform using the original XML posted and the original style sheet, I get an error indicating the stylesheet requires the version attribute.
If however I command line transform using the second style sheet I get well formed HTML. If I create an HTML output file, I can open it with IE, and the results are as desired.
Can anyone duplicate these results?
Any other thoughts folks?
Regards, Guy
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Huh.
I have a (shortly to expire) eval copy of XMLWriter installed.
WHen I run a transform using the 1st style sheet, the italics happen but the boldness does not!
When I run a transform using the 2nd style sheet, I get the style sheet as output!!!
I'm not sure about this problem, but I do think I'll let my copy of XMLWriter expire and just uninstall it.
Regards, Guy
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ha! Interesting experiment "client-side transformation with IE". What your clients will see, if you trust IE to perform transformation ...
I suspect that those of you who see blank page use old version of MSXML (versions 2.0 or 2.6). You can check which version your IE uses here: http://www.vbxml.com/parsers/sniffer/default.asp
I remember reading somewhere that old MSXML
1) did not work with template match="/" correctly
2) did not provide default built-in templates.
Full list of XSLT conformance (or inconformance) notes is here: http://www.vbxml.com/xsl/XSLTRef.asp
If you use MSXML 3.0 and still cannot see
Welcome to Northington company
please, say it here!
Anyway, it's already clear that perfoming XSLTransformation in client browser may bring many exciting minutes to XSLT developers. That's why server-side transformation is usually preferred.
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

To view the transformation in IE probably you need to install the latest MSXML4.0 parser
http://www.microsoft.com/downloads/release.asp?ReleaseID=29163
to view your transformation you can place your xml,xsl and following html in same directory
and open the html in IE .
<html>
<body>
<script language="javascript">
// Load XML
var xml = new ActiveXObject("Msxml2.DOMDocument.4.0")
xml.async = false
xml.load("myxml.xml")
// Load the XSL
var xsl = new ActiveXObject("Msxml2.DOMDocument.4.0")
xsl.async = false
xsl.load("myxsl.xsl")
document.write(xml.transformNode(xsl))
</script>
</body>
</html>
think this will work for client side transformation in IE .
also make sure to use
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" namespace in xsl.

thanks,
kripal
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
1.I DONT think IE5.0(may be 5.5 also) supports the namespace:
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
I hope we will have to use
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" version="1.0">
only.
2.can anybody please clarify the code fragment:
<headline>Welcome to <b>Northington</b> company</headline>
Vs
<i><xsl:apply-templates select="advertisement/text/headline"/></i>
Vs
<xsl:template match="b">
<xsl:copy-of select="."/>
</xsl:template>
3.Further,is "xsl:copy-of" supported by IE5.0/say xmlns:xsl="http://www.w3.org/TR/WD-xsl"?

regards
madhu
 
It's just a flesh wound! Or a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic