RE: format XML string?
If you really need to view it, open the xml in IE or an xml editor like XML Spy. They will format it nicely for display regardless of the file's formatting. M!ke ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207588 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
> Your method works, but it doesn't do indentation. I'll look more into it. Thanks. Yes, the XSLT code I posted is too generic for doing indentation too. You have to customize it, that's why I said it was a starting point. Massimo Foti Tools for ColdFusion and Dreamweaver developers: http://www.massimocorner.com ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207587 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
Your method works, but it doesn't do indentation. I'll look more into it. Thanks. Johnny >> So I don't see how XSLT can play a role here. > >It can play a role, because you can post-process your XML string using XSLT >as "pretty printer". >Try the code below (hope carriage returns will not break it): > > >xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> > > > > > > > > > > >first itemsecond >item > > >#XmlTransform(xmlStr, xslStr)# > > >Massimo Foti >http://www.massimocorner.com/ > >It should be this hole in the ozone layer >But I am not the coder I use to be... ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207586 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: format XML string?
>If you export the string to a file, and let your XML-aware text editor (or >other XML reader software like a browser) know it's an XML file (typically >by the file extension), the text editor will automatically display it as a >tree. Unfortunately, the current version of Dreamweaver doesn't seem to do >this. This would not work for me either as I name all my xml files with .xml.cfm extension. >This is common - XML parsers will often remove extraneous space when writing >the XML string. You will have to rewrite the string using regular string >formatting functionality after you've modified it using XML parsing >functionality. You mean like using replaceNoCase() function and search for > http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207581 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
> So I don't see how XSLT can play a role here. It can play a role, because you can post-process your XML string using XSLT as "pretty printer". Try the code below (hope carriage returns will not break it): http://www.w3.org/1999/XSL/Transform";> first itemsecond item #XmlTransform(xmlStr, xslStr)# Massimo Foti http://www.massimocorner.com/ It should be this hole in the ozone layer But I am not the coder I use to be... ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207578 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: format XML string?
> Also some of you missed my point, I am trying to format it so > it would look readable when I modify it in Dreamweaver or > CFEclipse. I don't have problem viewing it in IE or on a web > page. So I don't see how XSLT can play a role here. If you export the string to a file, and let your XML-aware text editor (or other XML reader software like a browser) know it's an XML file (typically by the file extension), the text editor will automatically display it as a tree. Unfortunately, the current version of Dreamweaver doesn't seem to do this. > I spoke too soon, Kerry. It didn't work. The toString() > function seems to work properly when you create the file for > the first time, but when you access an existing xml file and > modify it with the xmlElemNew() and other xml functions, then > the output is just one long string. This is common - XML parsers will often remove extraneous space when writing the XML string. You will have to rewrite the string using regular string formatting functionality after you've modified it using XML parsing functionality. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207576 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
> This should work fine (if slowly) asside from the fact that you need > to add xmlformat() around the attribute and text node values. Thanks, I'll add them in if I ever need to use it again. It was put together in about 10 minutes for debug purposes a while back when I couldn't use a browser (dump of something inside a CFC to a text file), so it's definitely a don't-use-this-for-anything-real snippet. -Joe -- Get Glued! The Model-Glue ColdFusion Framework http://www.model-glue.com ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207574 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: format XML string?
I spoke too soon, Kerry. It didn't work. The toString() function seems to work properly when you create the file for the first time, but when you access an existing xml file and modify it with the xmlElemNew() and other xml functions, then the output is just one long string. Also some of you missed my point, I am trying to format it so it would look readable when I modify it in Dreamweaver or CFEclipse. I don't have problem viewing it in IE or on a web page. So I don't see how XSLT can play a role here. Johnny > Yes, I do have the need for that. That is why I asked. I > auto-generate the circuit.xml files, but I want other developers to be > able to manually edit them if needed without any difficulty. > > Kerry, your suggestion seems to do the trick. Thank you. > > Johnny > > >> Is there a way to format the xml string before writing back > >> to the file? The problem I have is when I use > >> toString(xmlObject) to convert the xml object to string to > >> write to a file, it becomes one long ugly string. Is there > >> an easy to format it with indentation and all? > > > >I would strongly recommend that you not attempt to format the XML > string. > >There's no need to do that. > > > >Dave Watts, CTO, Fig Leaf Software > >http://www.figleaf.com/ > > > >Fig Leaf Software provides the highest caliber vendor-authorized > >instruction at our training centers in Washington DC, Atlanta, > >Chicago, Baltimore, Northern Virginia, or on-site at your location. > >Visit http://training.figleaf.com/ for more information! ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207572 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
"Johnny Le" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Yes, I do have the need for that. You can try a "pretty printer" XSLT. This should be a starting point: http://www.w3.org/1999/XSL/Transform";> Hope it will help Massimo Foti Tools for ColdFusion and Dreamweaver developers: http://www.massimocorner.com ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207569 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: format XML string?
If you're just looking to quickly see your output, You could just write it out and set the content type of the page. Kevin -Original Message- From: S. Isaac Dealey [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 24, 2005 12:23 PM To: CF-Talk Subject: RE: format XML string? >> Is there a way to format the xml string before writing >> back >> to the file? The problem I have is when I use >> toString(xmlObject) to convert the xml object to string >> to >> write to a file, it becomes one long ugly string. Is >> there >> an easy to format it with indentation and all? > I would strongly recommend that you not attempt to format > the XML string. > There's no need to do that. If you want clean, friendly formatting to peruse the xml document, just write it to a local file on your machine and open it in Firefox or IE -- both of them have default xml style sheets that make examining xml docs easier. s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207568 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
> Not with CF natively. XML (like HTML) is whitespace > agnostic, so the > XML doesnt care if it's one long line, or a nicely > formatted > (according to an arbitrary human). You could probably > write a > formatter fairly easily, depending on the complexity of > the formatting > rules you wanted to enforce. > At it's simplest, just do replace(xmlString, ">", > ">#chr(10)#", > "all"), but that'll only give you linebreaks, you'll have > to write an > actual parser that tracks nesting depth if you want to do > indentation > and stuff. Come to think of it there might be a way to get the formatting straight with a reasonably simple XSLT template also... XML to Text I'd have to look into it. s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207564 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: format XML string?
Yes, I do have the need for that. That is why I asked. I auto-generate the circuit.xml files, but I want other developers to be able to manually edit them if needed without any difficulty. Kerry, your suggestion seems to do the trick. Thank you. Johnny >> Is there a way to format the xml string before writing back >> to the file? The problem I have is when I use >> toString(xmlObject) to convert the xml object to string to >> write to a file, it becomes one long ugly string. Is there >> an easy to format it with indentation and all? > >I would strongly recommend that you not attempt to format the XML string. >There's no need to do that. > >Dave Watts, CTO, Fig Leaf Software >http://www.figleaf.com/ > >Fig Leaf Software provides the highest caliber vendor-authorized >instruction at our training centers in Washington DC, Atlanta, >Chicago, Baltimore, Northern Virginia, or on-site at your location. >Visit http://training.figleaf.com/ for more information! ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207563 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
This should work fine (if slowly) asside from the fact that you need to add xmlformat() around the attribute and text node values. > If it helps, I wrote a little UDF for this...can't > guarantee it'll be > 100% on all of the time, I scrawled it out quickly for my > own quick > use a while back. > output="false"> > > > >"<#arguments.xmlNode.xmlName#" /> > item="i"> > #i#=""#arguments.xmlNode.xmlAttributes[i]#"""> > >arrayLen(arguments.xmlNode.xmlChildren)> > > > " /> > >arguments.depth + 1) & > htmlEditFormat(arguments.xmlNode.xmlText) & > chr(10) /> > > > > to="#arrayLen(arguments.xmlNode.xmlChildren)#" index="i"> > prettyXml(arguments.xmlNode.xmlChildren[i], > arguments.depth + 1) /> > >arrayLen(arguments.xmlNode.xmlChildren)> > arguments.depth) & > "" & chr(10) /> > > > s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207562 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: format XML string?
>> Is there a way to format the xml string before writing >> back >> to the file? The problem I have is when I use >> toString(xmlObject) to convert the xml object to string >> to >> write to a file, it becomes one long ugly string. Is >> there >> an easy to format it with indentation and all? > I would strongly recommend that you not attempt to format > the XML string. > There's no need to do that. If you want clean, friendly formatting to peruse the xml document, just write it to a local file on your machine and open it in Firefox or IE -- both of them have default xml style sheets that make examining xml docs easier. s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://www.fusiontap.com http://coldfusion.sys-con.com/author/4806Dealey.htm ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207560 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
If it helps, I wrote a little UDF for this...can't guarantee it'll be 100% on all of the time, I scrawled it out quickly for my own quick use a while back. " /> " & chr(10) /> On 5/24/05, Barney Boisvert <[EMAIL PROTECTED]> wrote: > Not with CF natively. XML (like HTML) is whitespace agnostic, so the > XML doesnt care if it's one long line, or a nicely formatted > (according to an arbitrary human). You could probably write a > formatter fairly easily, depending on the complexity of the formatting > rules you wanted to enforce. > > At it's simplest, just do replace(xmlString, ">", ">#chr(10)#", > "all"), but that'll only give you linebreaks, you'll have to write an > actual parser that tracks nesting depth if you want to do indentation > and stuff. > > cheers, > barneyb > > On 5/24/05, Johnny Le <[EMAIL PROTECTED]> wrote: > > Hi, > > > > Is there a way to format the xml string before writing back to the file? > > The problem I have is when I use toString(xmlObject) to convert the xml > > object to string to write to a file, it becomes one long ugly string. Is > > there an easy to format it with indentation and all? > > > > Johnny > -- > Barney Boisvert > [EMAIL PROTECTED] > 360.319.6145 > http://www.barneyb.com/ > > Got Gmail? I have 50 invites. > > ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207559 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: format XML string?
> Is there a way to format the xml string before writing back > to the file? The problem I have is when I use > toString(xmlObject) to convert the xml object to string to > write to a file, it becomes one long ugly string. Is there > an easy to format it with indentation and all? I would strongly recommend that you not attempt to format the XML string. There's no need to do that. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207551 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: format XML string?
parse it into an xml object, then use: xmlobj.getDocumentElement().toString() except that will probably Unicode format it, dunno if theres a unicode2msdos() function floating around anywhere... -Original Message- From: Johnny Le [mailto:[EMAIL PROTECTED] Sent: 24 May 2005 18:36 To: CF-Talk Subject: format XML string? Hi, Is there a way to format the xml string before writing back to the file? The problem I have is when I use toString(xmlObject) to convert the xml object to string to write to a file, it becomes one long ugly string. Is there an easy to format it with indentation and all? Johnny ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207550 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: format XML string?
Not with CF natively. XML (like HTML) is whitespace agnostic, so the XML doesnt care if it's one long line, or a nicely formatted (according to an arbitrary human). You could probably write a formatter fairly easily, depending on the complexity of the formatting rules you wanted to enforce. At it's simplest, just do replace(xmlString, ">", ">#chr(10)#", "all"), but that'll only give you linebreaks, you'll have to write an actual parser that tracks nesting depth if you want to do indentation and stuff. cheers, barneyb On 5/24/05, Johnny Le <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a way to format the xml string before writing back to the file? The > problem I have is when I use toString(xmlObject) to convert the xml object to > string to write to a file, it becomes one long ugly string. Is there an easy > to format it with indentation and all? > > Johnny -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207549 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54