Jump to content

xslt Edit xml question...


Recommended Posts

I have the file horario.xml and I want convert horario.xml in different xml through an xslt stylesheet.I'm going to file it horario.xml I link to the stylesheet .. using ..<? xml-stylesheet href = "exercise1.xsl" type = "text / xsl">In exercise1.xsl I have as an output:<xsl:output method="xml" />And from there I do not know which is exactly what you need to do .... Greetings.... :good:

Link to comment
Share on other sites

Well the xml-stylesheet processing instruction is mainly used by browsers to automatically transform an XML document loaded in a browser window with the referenced stylesheet. On the other hand most browser like Mozilla or IE expect you to transform XML to some format they know to render, e.g. XML to XHTML or to XHTML plus SVG. So if you want to transform XML to XML then trying this inside of the browser is not necessary a good environment to test such transformation. As for how to do XML to XML transformation, assuming you have the input

<root>   <list>	 <item>foo</item>	 <item>bar</item>  </list></root>

and you want to transform that to XHTML then you simply write templates performing the transformation e.g.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"  xmlns="http://www.w3.org/1999/xhtml">   <xsl:output indent="yes"/>   <xsl:template match="/">	 <html xml:lang="en">		 <head>		    <title>Example</title>		 </head>		 <body>		    <h1>Example</h1>		    <xsl:apply-templates/>		 </body>	  </html>  </xsl:template>   <xsl:template match="list">	  <ul>		 <xsl:apply-templates/>	  </ul>  </xsl:template>   <xsl:template match="item">	  <li>		 <xsl:apply-templates/>	  </li>   </xsl:template> </xsl:stylesheet>

See it online at http://home.arcor.de/martin.honnen/xslt/test2013042501.xml. So whether you want to transform XML to HTML or to XML does not make much of the difference as to how you write stylesheets, you simply write templates matching the nodes in the input XML and you create result elements of the output XML or HTML.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...