• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML + XSL => HTML

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone say why when i want convert to html from xml and xsl using Apache xalan , i get in output
<?xml version="1.0" encoding="UTF-8" ?>
<MY_NEEDED_OUTPUT>
this line ?

my xml
<?xml version="1.0"?>
<doc>Hello</doc>

my xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="doc">
<h2><xsl:value-of select="."/></h2>
</xsl:template>
</xsl:stylesheet>

and output i have:

<?xml version="1.0" encoding="UTF-8" ?>
<H2>Hello</H2>

Transformation i do this way:
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource("./foo.xsl"));
transformer.transform(new StreamSource("./foo.xml"), new StreamResult(new StringWriter));

Thx
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I must have difficulty understanding what you're asking because to me it seems like your output is exactly what you want it to be?
 
Denis Yuzvyk
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But i want it only produce <h2> HEllo </H2>
i, want put this prodused peace to html page ...
but with first produced line(<?xml ...... > )
broused think it xml data , not html ...
how to deal with this ?
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add the html tags with it..
like <html><body> ....</body></html
 
Denis Yuzvyk
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found mistake , i need in xsl following line :
<xsl utput method="html" indent="no" />
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic