Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Generate a new XML doc

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 4/2/2004 1:19:00 PM

Tim:. wrote:

> Can someone tell me how I generate a new XML file that I can then use
> with an XSLT file. I am trying to use an XML file generated from
> Microsoft Project or even better generate an XML file from the
> project file (MPP File) itself. Which I can then use with an XSLT
> file.
> 
> I am new to XML and want to create a project viewer using XML, ASP
> and XHTML. I have an idea of how this should work but would really
> appritiate any help someone can offer. Is it possible to take an XML
> file and generate it in ASP without using an XSLT file???

If you want to create an XML document in memory you can use the DOM, 
MSXML is the component that supports that, if you want to do it a lot 
you might want to download MSXML 4 from msdn.microsoft.com, it comes 
with an SDK documentation.
Here is an example ASP page that creates a DOM document with a root 
element <riders> and two child <rider> elements and then outputs it to 
the browser by transforming it to HTML:

<%@ Language="VBScript" %>
<%
Option Explicit
Dim XmlDocument, XmlElement, XslDocument
Set XmlDocument = Server.CreateObject("Msxml2.DOMDocument.4.0")
XmlDocument.AppendChild(xmlDocument.CreateElement("riders"))
Set XmlElement = XmlDocument.CreateElement("rider")
XmlElement.AppendChild(XmlDocument.CreateTextNode("Armstrong"))
XmlDocument.DocumentElement.AppendChild(XmlElement)
Set XmlElement = XmlDocument.CreateElement("rider")
XmlElement.AppendChild(XmlDocument.CreateTextNode("Ullrich"))
XmlDocument.DocumentElement.AppendChild(XmlElement)

Set XslDocument = Server.CreateObject("Msxml2.DOMDocument.4.0")
XslDocument.Async = False
XslDocument.Load(Server.MapPath("test20040402Xsl.xml"))

XmlDocument.TransformNodeToObject XslDocument, Response
%>

The XSLT example is

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

<xsl:output method="html" indent="yes" encoding="UTF-8" />

<xsl:template match="/">
   <html>
     <head>
       <title>Riders</title>
     </head>
     <body>
       <xsl:apply-templates select="riders" />
     </body>
   </html>
</xsl:template>

<xsl:template match="riders">
   <ol><xsl:apply-templates select="rider" /></ol>
</xsl:template>

<xsl:template match="rider">
   <li><xsl:value-of select="." /></li>
</xsl:template>

</xsl:stylesheet>


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/



transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent