Title: Message
the xmlxslt.pdf file is very informative.  Thank you. 
 
So, should you use <cfxml> to make the xml document that's stored in the database available for processing?  I've successfully stored the xml document in my database using <cfsavecontent>.  Now, I'm further along in my application and need to interact with the xml document.  The examples I've seen with <cfxml> show it working by reading the xml document as if it were stored in a file (using <cffile>) versus pulling the document from a table.  I've tried this:
 
<cfxml variable="xmlDocument">#qry_GetXML.xmlDocument#</cfxml>
 
But I get an error message stating Document root element is missing.  I know the xml document has a root element.  I can paste the xml document into an xml validator and it checks out.  Any insight would be helpful please.
 
I've also tested the document using IsXMLDoc() and it returns No.
 
Should the xml document that's stored in the database have the XML Declaration, or will <cfxml> tag add the declaration automatically?
 
Thanks - Tom
-----Original Message-----
From: Askew, Jason [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 13, 2002 9:27 AM
To: '[EMAIL PROTECTED]'
Subject: RE: [cf-xml] CFXML question

I think part of the problem here is semantics.  What you think is a 'XML Document' and what MX thinks is an 'XML Document' are two different things:
 
As you are the think of them, An XML document is just some text in a specific format.  So, when you use <cfsavecontent>, you fill a variable with your type of text XML document.
 
However, when you use <cfxml> to encompass the same text, you create MX's type of a XML document, which is an object very much like a structure, not just a string.
 
So, if you are just trying to save XML text into a character field in a database, just use cfcontent to save the xml into a string.
 
If, on the other hand, you want MX's version of a XML document, with all it's bells and whistles (again, PLEASE refer to http://www.macromedia.com/desdev/mx/coldfusion/articles/xmlxslt.pdf) then you'll want to use CFXML.
 
So, using your code as before:
 
<cfxml variable="variables.testXML">
   <RootElement>
    <PersonnelProfile>
     <numStructureID/>
     <numPersonnelID/>
     <FirstName/>
     <LastName/>
     <email/>
     <phone/>
     <department/>
    </PersonnelProfile>
...
   </RootElement>
  </cfxml>
 
Now you have a XML Document called testXML.
 
Here's my SQL INsert:
 
  <cfquery name="qryInsert" datasource="#Request.DSN#">
   SET NOCOUNT ON
   INSERT INTO TABLE_NAME(
    txtName
    ,txtDescription
    ,numAuthorID
    ,txtXML
   )
   VALUES(
    '#trim(Arguments.txtName)#'
    ,'#trim(Arguments.txtDescription)#'
    ,#client.numPersonnelID#
    ,'#variables.testXML.ToString#'
   )
   SELECT @@IDENTITY [NewId]
  </cfquery>
 
Notice the addition of 'ToString' in the code.  This is a function of the  XML Document object created using <cfxml> that returns the 'string' of the XML doc.
 
Does that help?

Reply via email to