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

  • Home
  • SEARCH
  • 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 7676309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:10:15+00:00 2026-05-31T17:10:15+00:00

I am producing a XML file by the help of JAXB. public String getPrices()

  • 0

I am producing a XML file by the help of JAXB.

public String getPrices() {
    StringWriter writer = new StringWriter();
    JAXBContext context;
    try {
        context = JAXBContext.newInstance(AllMerchandises.class);
        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        m.marshal(this.allMerchandises, writer);
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return writer.toString();
}

the resulting XML String looks like this.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:merchandises xmlns:ns2="example/test/workspace">
<merchandise id="1">
    <name>Cat</name>
    <price>50</price>
</merchandise>
<merchandise id="2">
    <name>Dog</name>
    <price>100</price>
</merchandise>
<merchandise id="3">
    <name>Ape</name>
    <price>150</price>
</merchandise>
<merchandise id="4">
    <name>Gorilla</name>
    <price>200</price>
</merchandise>
<merchandise id="5">
    <name>Elephant</name>
    <price>250</price>
</merchandise>
</ns2:merchandises>

It is my task that the document could be showed a little bit designed in a browser by using XSLT. Therefor I need to include the .xsl in my XML file. Is there a maybe a way to tell the JAXB marshaller to make a inclusion? What could I do otherwise?
I need to include sth like this as 2nd line:

<?xml-stylesheet type="text/xsl" href="myfile.xsl"?>

thanks for every good idea

  • 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-31T17:10:16+00:00Added an answer on May 31, 2026 at 5:10 pm

    Finally I ended up using the same solution as described in this thread.

    Making JAXB generate an XML processing instruction

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have <supportedProfiles>extendedDesktop</supportedProfiles> in my Application.xml file, but the following is producing this error:
I'm producing a XML file and need to know if I can have '
I'm producing XML right from PL/SQL in Oracle. What is the preferred way of
I'm exploring the XML -> XSLT -> HTML meme for producing web content. I
I'm producing a hex file to run on an ARM processor which I want
I see a LOT of resources about producing feeds from T-SQL2005, about parsing XML
The following is a MXML Module I am producing in Flex 4: <?xml version=1.0
I am creating an XML file which is based upon the Atom 1.0 specification.
i have the following question: I have a XML file with some elements that
I am having a problem producing a working jar file. I would like to

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.