|
The application that I'm currently looking at XML for is to make my data human readable (power user, not normal user!!) and enable them to customise reporting, formatting and querying of the data. I see access to XSLT functionality as being the main reason to use XML.....
Out of curiosity, why is XML a better solution for you than a database using SQL to query and format simple things and using existing reporting tools for more complicated reporting?
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka
|
|
|
|
|
We are looking at low (computer) skill, price sensitive users.
XSLT was considered easier for our userbase to understand - or at least not mess up too badly, then SQL.
ASCII files that could easily be edited was also considered an advantage.
The inclusion of XML on (most) windows systems (our only target platform) without royaltys etc.
We need/would like to support the input/output of a number of already existing XML schema. (Is this "because everyone else is doing it"?) These Schema map poorly to our system, and we have a history of "lookup" and "mapping" files. XSLT will hopefully remove a lot of that from our coding.
We have not yet released anything XML, so what the actual reality is remains to be seen!!!!
|
|
|
|
|
I generally agree with Christians response but here are my 2 cents.
Marc Clifton wrote:
What are the pros and cons of XML?
Pros. You can create and transmit your data in an XML format with your tool set and I can read it with my tool set. Language and platform independant. No need to write a custom routine for each set of data (other than using the parsing tools in my app. If you have documented your information with a schema I can test your file and see if it conforms. You can also test my data when I return info to you. I can extend your data with additional info and extend your schema if needed. Your data is still consistent and usable with my additions doing nothing to the processing sequence of yoru data. Where do I stop?
Cons. TO many people believe in magic. Since XML is the in buzz word it will be missued and then discarded as not being a good solution when it may be.
Marc Clifton wrote:
What problems does XML solve?
For me it is mostly data transmission and reformating. I have a lot of data that must be displayed for review and then used in applications. I can XMLize the data stream from the data source and then apply the appropriate transformation for the usage at hand. This now gives me one authoritive data source for all usage. I can not tell you how many millions of dollars I know have been lost due to not having one authoritive set of data, but multiple that were not really handled correctly.
Marc Clifton wrote:
When is XML a good solution for a problem, and when isn't it?
Rather open question. It is a good solution to the above items that I mention plus more. It is not a good solution to use for massive data migration tasks. For example I have done a lot of finite element work. Now a typical run may produce a binary data set that is say 20 gig in size. It would be rediculus to handle this entire set of data as an XML file. If you just need to send a small set of data from a query then query the data and XMLize the results to send.
Marc Clifton wrote:
Self-defining data structure. So what?
Not just self defining structure but in the way it is structured. The ability to now use XPath and XSLT to find and process what I need as well as a standard method to describe the data schema is very powerfull. How do I process your flat file with my tool set?
Marc Clifton wrote:
It seems that XML is inefficient space wise, parsing is slow, and human readability is poor.
OK compared to what. ASCII is inefficient so lets ban that. The question is what do we gain. Now as stated earlier you can missuse it.
Parsing is slow, again compared to what? Parsing is much faster than me having to open your file and copy and paste the data I need.
Readability: have you ever had to go sort out a flat file that did not have the proper documentation or worse a binary. I have had to do both.
Now if none of the above impacts you XML may very well not apply to your task. It is not a magic solution that solves all of the worlds problems.
You mentioned your flat file. You may ask yourself how it is being used. Only for your app which never needs to be transfered or migrated? Then leave it be. It may be best to add export import to your solution than to use XML as the native format. THen if you do need these options you have it built in.
"I will find a new sig someday."
|
|
|
|
|
Thanks Michael, that put some things into perspective. Particularly your last comment--Only for your app which never needs to be transfered or migrated? This was something that was bothering me--people were recommending I use XML when the flat file is really application specific--none of the data needs to be transmitted to another app.
It seems that XML is a good tool to use when transferring data between applications is an issue.
But from what you and others have said, it also seems that it is a good tool for parsing and validation, regardless of inter-application issues.
The thing that bothers me is that I can, for example, edit a flat file that describes a menu structure much more easily that I can edit a similar XML file. It seems that even simple data structures need some sort of an editor to make the data more user friendly. Thoughts?
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka
|
|
|
|
|
Marc Clifton wrote:
The thing that bothers me is that I can, for example, edit a flat file that describes a menu structure much more easily that I can edit a similar XML file.
For something like an outline of a book. I absolutly agree.
Marc Clifton wrote:
But from what you and others have said, it also seems that it is a good tool for parsing and validation, regardless of inter-application issues.
Yes but for interapp usage I would think once the tools have been tested this in not the issue that it is for data between apps and companies.
Marc Clifton wrote:
It seems that even simple data structures need some sort of an editor to make the data more user friendly. Thoughts?
I would not plan for the raw XML file to be edited and manipulated by end users if this is a common task to be done. Yes go create an editor if the data is XML or not.
Now if the data is available in XML (native or export/import) then if a power user does need to do something the likely hood that they can figure it out is much greater. They can then create the editor they need for their task with your format. I would also expect to have a schema available. My band wagon here. Please use XSD and not DTD's, why use non-XML to describe XML.
"I will find a new sig someday."
|
|
|
|
|
XML is a readable compound document file format (IStorage/IStream folders/files metaphore). At each level you may have an arbitrarily deep set of children, and so on. That's why it simplifies versioning a lot over time : no need to break a file format, just add new storages.
|
|
|
|
|
I have this code snipet in my c# classs that generates a string containg xml data.
//build xml data
StringWriter xmlStringWriter = null;
XmlTextWriter xmlWriter = null;
string xmlString = "";
StringBuilder xmlStringBuilder = new StringBuilder();
try
{
xmlStringWriter = new StringWriter(xmlStringBuilder);
xmlWriter = new XmlTextWriter((xmlStringWriter);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteStartDocument(); //start document
//populate xml
However, the generated xml string contains the header as:
Does anybody know of a way to use enconding "utf-8" when building an xmldoc inside a string?
|
|
|
|
|
It appears that you did not check the display message as-is (no HTML).
Are you trying to save an XML document inside a single string to then include in a second instance of something else (be it a XML doc or what ever?)
"I will find a new sig someday."
|
|
|
|
|
I have a problem with converting all serialized data of MFC Object such as COleClientItem, CDocItem and CObject to XML. I would appreciate it if someone could suggest me how to solve this problem.
Thank very much for your help.
|
|
|
|
|
I think you need to be a little more explict on what you are asking. A CObject can contain anything so your question is really how do I serialize all possible data in all formats as XML.
"I will find a new sig someday."
|
|
|
|
|
Not sure if this is the right place to post, but...
I am trying to read and write attributes from a DOM.
The attributes are of type base64Binary, and I am using IXMLDOMElement::setAttribute(BSTR, VARIANT). How to I package/assign binary data (currently a CDWordArray, but I'm very flexible!!) into/from the variant?
Thanks!!!
|
|
|
|
|
Using BSTR, Variant should be fine but keep in mind that the memory block you are writting to the document must be compliant with allowed characters. This is espcially true with using the attribute data blocks vs a CData section. Just think of handling the transmission over a http connection. You would have to encode/decode the data. The same concept can apply here. Encode the binary into a string and set it to be the attribute value is one path I have used for smaller sets of information.
"I will find a new sig someday."
|
|
|
|
|
Thanks, no one seems to know much about this.....
I have no experiance with http connections/communictions. Is it possible for you to dumb it down a bit?
Encoding/decoding to me means stripping out the " ", "<", ">" etc characters, and replacing them when reading. Is this true? Are you aware of any functions available that will do this for me? I've found http://www.codeproject.com/internet/mimesniffer.asp Is this the sort of thing I should be using?
My data will typically go to 20 to 30 attributes, each of which will be less than 1 KByte.
|
|
|
|
|
Here is some code I did awhile back.
You need to remove nondisplay as well as conflicting characters from the display.
CString EnCodeStr(CString ToCode)
{
CString RetStr,AddStr;
int i,max;
unsigned short asc;
unsigned char c;
max = (unsigned int)ToCode.GetLength();
// For binary you need to send the length, The block could have zeros
for(i=0;i<max;i++)
{
c =="" tocode[i];
asc="c;
if(asc">47 && asc<58)
{
RetStr+=c;
}
else if(asc>64 && asc<91)
{
RetStr+=c;
}
else if(asc>96 && asc<123)
{
RetStr+=c;
}
else if(asc==32)
{
RetStr+="+";
}
else
{
AddStr.Format("%%%02x",asc);
RetStr+=AddStr;
}
}
return RetStr;
}
CString DeCodeStr(CString ToCode)
{
CString RetStr,AddStr;
int i,max;
unsigned short asc;
unsigned char c;
max = (unsigned int)ToCode.GetLength();
for(i=0;i<max;)
{
c =="" tocode[i];
asc="c;
if(asc==37)
{
AddStr=ToCode.Mid(i+1,2);
i+=3;
sscanf((LPCTSTR)AddStr,"%2x",&asc);
RetStr+=(char)asc;
}
else" if(asc="=43)
{
RetStr" +=" " ;
i++;
}
else
{
retstr="" retstr;
}
for="" smaller="" blocks="" that="" you="" mention="" this="" should="" be="" ok.
now="" i="" am="" assuming="" a="" mfc="" solution="" is="" ok.
to="" get="" the="" data="" into="" string="" one="" option="" to="" use="" cmemfile="" detach()="" and="" attach()="" functions.
sorry="" do="" not="" have="" time="" sample.="" would="" think="" could="" search="" on="" above.
=""
<b="">"I will find a new sig someday."
|
|
|
|
|
That sample's great, thanks. My main concern was what you meant by coding and encoding. If that's good enough then fantastic!!!!
thanks again.
|
|
|
|
|
Glad it helped. Take care.
"I will find a new sig someday."
|
|
|
|
|
Maybe I am missing what Michael is getting at but I don't think he is entirely correct. The base64Binary datatype by definition doesn't require any replacements to be legal in an xml document as when it is encoded it uses the characters 0-9 a-z A-Z '+' '/' ie no replacements required see section 6.8 of http://www.ietf.org/rfc/rfc2045.txt for details (this page is linked to by the Schema spec). Also be aware that most XML DOM do translations required ie you set strings containing '>' '&' etc and they will automatically be converted on output to < and &, however I'm not sure if this is the case for binary types.
If possible I would be tempted to use the hexBinary datatype as I find that easier to understand, two characters (0-9 a-f) are used to represent each hex octet ie 0x7f10 would be "7f10" in your XML doc.
Hope I haven't confused you...
|
|
|
|
|
No, that makes a bit more sense to me, and sounds easier to implement and check.
Is there an easy way to convert the 0x7f10 to "7f10"?
sprintf("%08h", intArray[0]) is OK for an int, but a bit tedious for arrays.
Is there a "short cut" here, or am I stuck with a loop?
Being able to calculate the length of the final string from the input string seems to me like a major advantage over Michael's code.
|
|
|
|
|
Thanks for correcting this. I guess I have been working to long. I totally over looked base64Binary was mentioned and just read a binary memory block in a BSTR field.
Take Care.
"I will find a new sig someday."
|
|
|
|
|
I use the MSXML IXMLDOMDocument to load and save settings of a Visual C++ Project. My code looks like this:
<br />
hr = Document.CoCreateInstance(__uuidof(DOMDocument));<br />
if (FAILED(hr) || (Document.p == NULL)) throw (IDS_XML_CANT_CREATE_XML_PARSER);<br />
<br />
VARIANT_BOOL Success = false;<br />
hr = Document->load(CComVariant(m_szFilename), &Success);<br />
if (FAILED(hr) || !Success) throw (IDS_XML_SETTINGS_CANT_LOAD_SETTINGS);<br />
Everything works fine and is square with the MSDN recommandations. But I still have a tiny problem: I decided to use XML in order to allow my users to manually edit the conf file but right now, the parser writes everything on a single row, making it hard to read.
It is important to tell the parser to write tabs, spaces and linefeeds ...
but how ???
|
|
|
|
|
Look for the whitespace settings (options). carraige returns and line feeds are just child text nodes.
Your users should be able to add the linefeed text manually and not impact your reading the data back in as a last option.
"I will find a new sig someday."
|
|
|
|
|
How come the "Copy Project" option in VS.NET is always disabled whenever I need to transfer a finished web service on my local computer to my remote web host's server? (I was always able to use this method to tranfer my ASP.NET projects).
Therefore, I had to copy the files manually via FTP. The files I copied were:
1) myService.asmx
2) myService.vsdisco
3) global.asax
4) web.config
5) bin folder which contains: myService.dll
All these files and the "bin" folder were copied to a folder called MyServiceFolder located at the root of my website's directory structure. But whenever I try to access the service (http://www.mysite.com/MyServiceFolder/myService.asmx) it fails. And it will not display the specific error because it could not locate the web.config (where <customerrors="off">).
However, when I move the web.config file out of the MyServiceFolder and into the parent folder, and tried it again, it was able to tell me the specific error: "Parser Error Message: Could not create type 'MyNamespace.MyClass'." But this means that my web service is still not working.
After some more trial and error, I was able to access my web service. What I did was that I also moved the "bin" folder out of the "MyServicefolder" and into the parent folder (where web.config is sitting). This made everything to work.
The location of my files on the server now looks like this (which is kinda too messy):
1) /web.config
2) /bin/myService.dll
3) /MyServiceFolder/myService.asmx
3) /MyServiceFolder/myService.vsdisco
4) /MyServiceFolder/global.asax
But the point is that I want to be able to organize all of my projects (web service, asp.net apps, etc) into their own folders on the server. So my big question is how can I put this web service into one folder such as MyServiceFolder, and make it work?
Is there some configuration/setup file where I can edit the path directories?
My other big question is how come I cannot use the "Copy Project" option to transfer web services to a remote server?
PLEASE HELP! Thanks.
|
|
|
|
|
Pls look at the link below so as to understand my problem..... its just a very short page so pls look at it.....
http://www.xmlfiles.com/articles/michael/htmlxml/default.asp
For the above link, the datas are being saved to xml using 'processForm.asp', if i cant use 'ASP' and my only choices are 'JSP' or 'Java' , 'XSL' to display. Can it be done???
Any websites that have similar examples or links will be greatly thankful.....
|
|
|
|
|
|
I am working on a parser using VC++ that utilizes MSXML 4.0. I have built a release version . I need to deploy this on another machine that doesnt have MSXML installed. How can I know which components(.ocx's or dll's) to include ?
Please help
|
|
|
|