Jump to content
hectorsales

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:

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...