Generic xslt needed to reproduce any xml file (doesn't have to be complicated)

Probably a simple one but anyone have any idea how I would produce an XSLT that would reproduce exactly any xml file?
madbastard09Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

J_MakCommented:
If you have this simple XML file:

<?xml version="1.0"?>
<samples>
      <sample>Hello</sample>
      <sample>How are you</sample>
</samples>

And this is your XSLT stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="xml"/>
      <xsl:template match="/">
            <samples>
                  <xsl:apply-templates select="samples"/>
            </samples>
      </xsl:template>
      <xsl:template match="samples">
            <xsl:for-each select="sample">
                  <sample>
                        <xsl:value-of select="concat(.,' there')"/>
                  </sample>
            </xsl:for-each>
      </xsl:template>
</xsl:stylesheet>

This will be your resultant XML file:

<?xml version="1.0"?>
<samples>
      <sample>Hello there</sample>
      <sample>How are you there</sample>
</samples>

So I have simply changed the XML file to include an extra string 'there'. This is a very simple example and I hope it is understandable. If you have any questions, please don't hesitate to ask. Cheers.
0
madbastard09Author Commented:
Fine, but if i needed an xslt to tranform ANY into its indentical state then any specified variables such as 'sample' should not be needed. I currently have this:

  <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > 
          <xsl:output method = "xml"  />

 <xsl:template match="@*|node()">
   <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
</xsl:template>


     </xsl:stylesheet>


but it just produces the data and not the tags!
0
J_MakCommented:
Why don't you just copy the whole XML file like so:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="xml"/>
      <xsl:template match="/">
            <xsl:copy-of select="."/>
      </xsl:template>
</xsl:stylesheet>

Cheers.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.