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 6789895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:39:37+00:00 2026-05-26T17:39:37+00:00

I am having a xml file as input to the xsl file. When i

  • 0

I am having a xml file as input to the xsl file. When i am specifying the outputmethod of xsl as xml and defining an element using xsl:element or matching an element from the xml as said in the other threads i am not getting any tags.I am getting only the text of the xml.I have tried various examples. Whatever i tried i am getting only the text part of the xml. Can you give me a simple example that contains full working code of transforming one xml into another xml using xsl.

Sorry for not posting the sample.

I tried restructuring of xml in two ways:

1) Having an xsl and xml file in the same folder and opening the xml using the browser.The xsl file is applied to the xml as below.

test.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<root>
<info>
    <firstname>Bob</firstname>
    <lastname>Joe</lastname>
</info>
<notes>
    <note>text1</note>
    <note>text2</note>
</notes>
<othernotes>
    <note>text3</note>
    <note>text4</note>
</othernotes>
</root>

sample.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="root">
   <root>
     <xsl:copy-of select="info"/>
     <notes>
        <xsl:copy-of select="othernotes"/>
     </notes>
   </root>
</xsl:template>
</xsl:stylesheet>

output:
Bob Joe text3 text4

Both the files are in the same folder and i opened the xml file using the browser to see the output.

2)In am using struts framework with xslt in my project. The xml set to the view is as follows.
XML:

<root>
<data>
<array-list>
<array-list xsi:type="java:java.util.ArrayList">
<slot-info-object avail-crit-thresh="-1.0" avail-fif-min="-1.0" avail-five-min="-1.0" avail-one-day="0.0" avail-one-hr="-1.0" avail-warn-thresh="-1.0" freeslot="0" keyn-service-subtype-id="9" perf-crit-thresh="-1.0" perf-fif-min="-1.0" perf-five-min="-1.0" perf-one-day="0.0" perf-one-hr="-1.0" perf-warn-thresh="-1.0" severity-type="0" shared-script-id="-1" slot-id="671457" trans-id="733299" user-id="0" xsi:type="java:com.keynote.mykeynote.service.dashboard.SlotInfoObject">
<slot-alias>Single slot</slot-alias>
</slot-info-object>
<slot-info-object avail-crit-thresh="-1.0" avail-fif-min="1.0" avail-five-min="1.0" avail-one-day="1.0" avail-one-hr="1.0" avail-warn-thresh="-1.0" freeslot="0" keyn-service-subtype-id="9" perf-crit-thresh="-1.0" perf-fif-min="0.5105" perf-five-min="0.529" perf-one-day="0.6195208333333333" perf-one-hr="0.5505" perf-warn-thresh="-1.0" severity-type="0" shared-script-id="595" slot-id="685397" trans-id="-7105" user-id="0">
<slot-alias>SharedSlot</slot-alias>
</slot-info-object>
</array-list>
</array-list>
</data>
</root>

The view is the xsl file that contains the following code:
XSL File:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/root/data/array-list/array-list">
<root>
<slot-info-object>
     <xsl:for-each select="slot-info-object">
     <xsl:copy-of select="slot-alias"/>     
     </xsl:for-each>
</slot-info-object>
</root>
</xsl:template>

</xsl:stylesheet>

output:
Single slotSharedSlot

One more Question:
request.setAttribute(StrutsCXConstants.XML_KEY, data);
Here data is the java collection like ArrayList. THis line is written in the struts Action file.This is only converted to the xml for the view.
When we are saying this in the xsl

<xsl:output method="xml" indent="yes"/>

should the response type in the Struts Action class must be set to “text/xml”

Thanks.

  • 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-26T17:39:37+00:00Added an answer on May 26, 2026 at 5:39 pm

    In my second case, I got the text because i didn’t set the response type to xml in my java action class. Once I set that, the xsl displays my own custom tags and the tags in the xml which i sent to the xsl.

    Regarding my first case, as Dimitre Novatchev said we have to use some command like the one given in the following link.
    http://www.biglist.com/lists/xsl-list/archives/199912/msg00082.html

    Thanks all for ur info.

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

Sidebar

Related Questions

I'm having a problem writing Norwegian characters into an XML file using C#. I
I'm using DOM to parse an xml file. And I am having trouble catching
I'm having trouble editing an XML file. I'm currently trying to use Nokogiri ,
I'm having trouble understanding why I would use a context.xml file to declare a
I am having on xml from which i have to remove the one book
After having converted a messed up XML using regex, I now need to change
I am having some issues receiving UTF-8 XML files back from DHL API. As
In my XSLT file, I have the following: <input type=button value= <xsl:value-of select=name>> It's
What's the difference between these two methods of reading an input file? 1) Using
I am having a xml file as: <Order> <EP> <Name>Generation Date</Name> <Value>2009-08-04+05:30</Value> </EP> <EP>

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.