Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6632013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:37:36+00:00 2026-05-25T22:37:36+00:00

I am trying to transform an xml file with xsl stylesheet into html. this

  • 0

I am trying to transform an xml file with xsl stylesheet into html.

this is the java

TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer(new StreamSource(classLoader.getResourceAsStream("driving.xsl")));
            StreamResult drivingHtml = new StreamResult(new StringWriter());
            transformer.transform(new StreamSource(classLoader.getResourceAsStream("driving.xml")), drivingHtml);
            System.out.println(drivingHtml.getWriter().toString());

this is some of the xml:

<?xml version="1.0" encoding="UTF-8"?>
<user xmlns="http://notreal.org/ns1" xmlns:poi="http://notreal2.org/ns2">
    <address type="primary">
        <street>1031 Court St.</street>
        <city>Monhegan, NY</city>
    </address>

    <address type="secondary">
        <street> Elm St.</street>
    </address>

this is the xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <html>
            <head>
            <title>User</title>
            </head>
             <body>
                <p>Detailed Addresses</p>
                <xsl:apply-templates select="/user/address"/>
             </body>
         </html>
    </xsl:template>

     <xsl:template match="address">
        <table>
            <th>Primary</th>
            <th>Secondary</th>
            <tr>
                          <td>
                    <xsl:value-of select="address" />
                           </td>
                 </tr>
            </table>
     </xsl:template>
</xsl:stylesheet>

when i run that, i get the html from the root template match, but nothing from the template matching address. i’ve tried other variations of templates, and instead of getting at least the basic html, i just get the entire contents of xml file ouputted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:37:37+00:00Added an answer on May 25, 2026 at 10:37 pm

    Check your namespace or or modify your XML to something like the following one to add a namespace-prefix:

    <?xml version="1.0" encoding="UTF-8"?>
    <user xmlns:a="http://notreal.org/ns1" xmlns:poi="http://notreal2.org/ns2">
      <address type="primary">
          <street>1031 Court St.</street>
          <city>Monhegan, NY</city>
      </address>
    
      <address type="secondary">
          <street> Elm St.</street>
      </address>
    </user>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to transform an xml file with xsl stylesheet into html. this
I'm trying to have a script automatically transform an xml file into several html
Something's screwy here. I'm trying to parse this XSL file: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet
I am trying to develop an XSLT stylesheet which will transform an xml into
I'm trying to use XSL-stylesheets in order to transform some generated XML-data to HTML-output.
I'm trying to query an xml file using the following xslt: <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform
I have an XML file and I'm trying convert it into a (table( HTML
I'm trying to transform one XML format to another using XSL. Try as I
i'm trying to implement an xsl file to an xml doc. however when i
I'm trying to decrypt an encrypted XML file and put it into a stream

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.