[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: RE: Transformation XML to XML
Hi, Thanks for the reply and your not kidding, so your help here would be great. Anyway, here goes, The XML is produced as a result of an Access Database query that is shown in the ASP (VBScript) file in my previous message. The table field names are used to create the XML tags. So in answer to your question is no actual XML file, its done on the fly. The following is what I currently get, but all in one long string. However, it's missing the root, which I need to add as part of the stylesheet. This is a sample of 2 image records; there will be hundreds of image records in the database. <image> <pdesc>hot rod</pdesc> <filename>ab_0001.jpg</filename> <photoid>223</photoid> <photogid>5</photogid> </image> <image> <pdesc>brass headlamps</pdesc> <filename>ab_0002.jpg</filename> <photoid>224</photoid> <photogid>5</photogid> </image> What I'm actually after is the following: converting the pdesc, filename, photoid and photogid as attributes of image with collection as the root. Eg. <collection> <image pdesc="hot rod" filename="ab_0001.jpg" photoid="223" photogid="5"/> <image pdesc="brass headlamps" filename="ab_0002.jpg" photoid="224" photogid="5"/> </collection> I hope this makes sense. I'm using Flash to read this and I'm told that it can read large amounts of XML a lot quicker if it is presented with attributes hence the reason for this. Cheers Rob. -----Original Message----- From: cknell@xxxxxxxxxx [mailto:cknell@xxxxxxxxxx] Sent: 19 July 2005 15:12 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: RE: Transformation XML to XML All the "disable-output-escaping" tells me you are struggling with the idea of XSLT. Please give a sample of the input file and we can put you on the right track. -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Rob Merrison <rob.merrison@xxxxxxxxxxxx> Sent: Tue, 19 Jul 2005 10:31:58 +0100 To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: RE: Transformation XML to XML Hi I need some help please with the following xslt stylesheet. I use this style sheet that gets pulled into the ASP file after the query is run on an ACCESS database. The output is xml. However the xml is not formed to the correct layout. This file is called ADOGeneric.xsl and is referenced in the ASP file. <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:z="#RowsetSchema"> <s:Schema id="RowsetSchema"/> <xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:template match="/"> <xsl:apply-templates select="//z:row"/> </xsl:template> <xsl:template match="z:row"> <xsl:text disable-output-escaping="no"><image></xsl:text> <xsl:for-each select="@*"> <xsl:text disable-output-escaping="no"><</xsl:text> <xsl:value-of select="name()"/> <xsl:text disable-output-escaping="no">></xsl:text> <xsl:value-of select="."/> <xsl:text disable-output-escaping="no"></</xsl:text> <xsl:value-of select="name()"/> <xsl:text disable-output-escaping="no">></xsl:text> </xsl:for-each> <xsl:text disable-output-escaping="no"></image></xsl:text> </xsl:template> </xsl:stylesheet> <%@ Language = VBScript %> <% Response.Expires = -1 Response.Buffer = True Dim conn, rs, xml, xsl Set conn = Server.CreateObject("ADODB.Connection") conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("gen_dib_data.mdb") & ";User Id=admin;Password=;" conn.Open Set rs = Server.CreateObject("ADODB.Recordset") Set rs.ActiveConnection = conn rs.Open "SELECT Photo.PDesc, Photo.Filename, Photo.PhotoID, Photo.PhotogID FROM Photo" alldata=rs.getrows() numcols=ubound(alldata,1) numrows=ubound(alldata,2) Set xml = Server.CreateObject("MSXML2.DOMDocument") Set xsl = Server.CreateObject("MSXML2.DOMDocument") xml.async = False xsl.async = False rs.Save xml, 1 'adPersistXML xsl.load Server.MapPath("ADOGeneric.xsl") Response.Write(lcase(xml.transformNode(xsl))) Set xsl = Nothing Set xml = Nothing rs.Close Set rs = Nothing conn.Close Set conn = Nothing %> The output currently looks like this, one continuous line: <image><pdesc>hot rod</pdesc><filename>ab_0001.jpg</filename><photoid>223</photoid><photogid>5 </photogid></image><image><pdesc>brass headlamps</pdesc><filename>ab_0002.jpg</filename><photoid>224</photoid><phot ogid>5</photogid></image> which I guess if I split it up it would look like this: <image> <pdesc>hot rod</pdesc> <filename>ab_0001.jpg</filename> <photoid>223</photoid> <photogid>5</photogid> </image> <image> <pdesc>brass headlamps</pdesc> <filename>ab_0002.jpg</filename> <photoid>224</photoid> <photogid>5</photogid> </image> I actually need an xslt script to produce the output to look like the following if this is possible with the added element collection: <collection> <image pdesc="hot rod" filename="ab_0001.jpg" photoid="223" photogid="5"/> <image pdesc="brass headlamps" filename="ab_0002.jpg" photoid="224" photogid="5"/> </collection> I tried this in order to achieve the results but this fails with the message below and I'm pretty sure this is almost correct. <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:element name="collection"> <xsl:for-each select="/collection/image" > <xsl:element name='{name()}'> <xsl:for-each select="*" > <xsl:attribute name='{name()}'> <xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template> </xsl:stylesheet> The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. ---------------------------------------------------------------------------- ---- Switch from current encoding to specified encoding not supported. Error processing resource 'http://thebes/ImageRealm_new_1... <?xml version="1.0" encoding="utf-16"?><collection></collection> ---------------------------------------^ many thanks Rob. --~------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --~--
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|