|
Maybe this is just personal preference, but I cringe when I see this:
<cities>
<city>
<name>Aberdeen</name>
</city>
<city>
<name>Dundee</name>
</city>
</cities>
All those nested tags are really hard to read (and make for more complex parsing code). I would write it as:
<cities>
<city name='Aberdeen' />
<city name='Dundee' />
</cities> Free-form and/or long text descriptions can go in their own tags, such as country/filemeta/about or country/history/event/summary
But I like your idea, if enough folks join in, the result could be an encyclopedia in XML.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
CP SearchBar v2.0.2 released
|
|
|
|
|
Thanks Mike - your input is very helpful. I was thinking that I was not taking advantage of attributes. Once I get a sample XSL online (important for people to see a sample output), I'll look again at the structure.
Michael Dunn wrote:
if enough folks join in, the result could be an encyclopedia in XML.
Yeah it has potential - the format and XSL is for any country so it would be nice to cover more that Scotland.
Davy
My Personal Blog - Homepage. Scottish News - Angus Blog, Perth Blog and Dundee Blog
|
|
|
|
|
I've just posted a couple of additions for you (SMG newspapers).
Have you thought about how you'll deal with aggregating data if you get a lot of submissions?
|
|
|
|
|
Thanks Niall - I have added your contributions.
Niall Barr wrote:
Have you thought about how you'll deal with aggregating data if you get a lot of submissions?
No not yet! Currently I am working on trying to build a Yahoo Group for the project and get a sample XSL together to showcase the data. The XML file needs some work - for example attributes are hardly used and could cut down number of tags.
Thanks for the interest!
Take care,
Davy
My Personal Blog - Homepage. Scottish News - Angus Blog, Perth Blog and Dundee Blog
|
|
|
|
|
Maybe a good start would be to define an extensible schema and to collect ideas for that schema (such as Mike Dunn's above). This could be a very useful thing, but publishing a schema will make it acceptable for many uses, so long as it is capable of handling many possibilities, and even allows for extension for the possibilities that are too rare to build-in, or ones that you or the community can't think of.
Also, and this *could* go along with the schema, using a namespace with namespace-qualified elements (perhaps even qualified attributes, like RDF requires), makes XML parsing easier since your elements would be qualified and couldn't get confused with other elements (by the XML parser that understands namespaces in most cases).
I think this is a really interesting idea. Good luck!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
I'm trying to use MSXML3 to read a XML document and populate a CTreeCtrl in MFC. But to populate the tree I have to go through the xml document as the tree structure would be different from the xml hierarchy. Someone asked me to use xml patterns for this. Can anybody supply me with some tutorial/sample code for xml pattern support of MSXML? also, I was wondering if I can use xml path for this? I don't have any idea about xml pattern or, xml path. so I'm looking for as much help as I can get on them. Please supply any code in C++ only
Thanks,
|
|
|
|
|
Does anyone know of a good beautifier for XML that works with Visual Studio? Unfortunately, for now I am stuck with Visual C++ 6.0, but I would like to use it to edit XML, and most of the XML I am working with is poorly formatted (actually, all one line).
I guess a reasonable follow up question would be, does anyone know of a good XML editor (that doesn't cost much)? But I would really prefer to do my editing in Dev Studio, so a plugin is still preferable.
Thanks,
Cagey
|
|
|
|
|
Hi,
I don't know about a beautifier, but have a look at www.firstobject.com, there will be an inexpensive (no cost) xml editor.
Regards
G. Steudtel
|
|
|
|
|
|
|
Certainly not a plugin, though you could add it to your tools menu easily enough. This is what I use:
using System.IO;
using System.Xml;
class FormatXml {
static void Main(string[] args) {
XmlTextReader r = new XmlTextReader(args[0]);
XmlTextWriter w = new XmlTextWriter(new StreamWriter(args[1]));
r.WhitespaceHandling = WhitespaceHandling.None;
w.Formatting = Formatting.Indented;
w.Indentation = 1;
w.IndentChar = '\t';
w.QuoteChar = '\'';
w.WriteNode(r, false);
w.Close();
}
}
Adjust the Indentation, IndentChar and QuoteChar properties to match your tastes.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Frontpage 2003 (ick!) beautifies XML. It is a very poor XML editor though (no surprise eh?).
|
|
|
|
|
I have an XSLT transform that's used to transform an XML file into WebControl treenodes. I'm wanting to use script in the transform, but in order to do so, I have to import the xmlns:msxsl namespace.
When I do this, that namespace is also imported into the first <TREENODE> of the resulting XML. This causes the treeview webcontrol to give the error "The data at the root level is invalid.". How do I stop this namespace from being imported into the resulting XML?
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Use the exclude-result-prefixes attribute on the stylesheet.
(Replying to my own post again!)
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
My team and I are working with XML, and want to use the MSXML parser. I've heard that the MSXML parser only comes with IE5 and above. Is there a way to distribute it with your app, or download it separately from IE5/6? We don't want to have to have a certain version of IE be a requirement for the use of our library.
Thanks!
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
|
Thanks!
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
What could be wrong here??? I get the error "Invalid at the top level of the document"; however, loading the exact same text from a file using load() works!
CoInitialize();<br />
<br />
CComPtr< IXMLDOMDocument2 > pDocument;<br />
pDocument.CoCreateInstance( CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER );<br />
<br />
VARIANT_BOOL status;<br />
<br />
pDocument->loadXML( BSTR( "< ParticleSystem />" ), &status );
|
|
|
|
|
Without checking this out it may be because of the BSTR constructor you are using. BSTR's are unsigned short pointers, while you are passing in a const char* so a pointer cast is probably done (by the compiler) so two characters from your const char will be going into one character of the BSTR ie could be any character!! I suggest you try using CComBSTR, _bstr_t, or SysAllocString (and a matching free) to create your string to parse...
|
|
|
|
|
Thanks for your help. I finally found that my problem was a combination of two different problems.
1. Here was the real problem: I was loading (as binary) a Unicode file that has a BOM (byte-order mark) at the front of the file. Then I passed the text to loadXML. Apparently, loadXML can't handle Unicode special characters. I consider this a bug in loadXML.
2. In order to test loadXML, I was creating a BSTR like this:
BSTR( "< ParticleSystem />" );
Like you said, the constructor was not converting the string to a Unicode string as I expected it to do. loadXML was able to parse this:
BSTR( L"< ParticleSystem />" );
|
|
|
|
|
If it's any consolation, I've hit that first problem too. My solution was to provide an IStream implementation that ate the BOM from it's input if present; it used memory mapped files so didn't ever call ReadFile...
Steve S
|
|
|
|
|
|
Michael Dunn wrote:
Jambolo wrote:
BSTR( L"< ParticleSystem />" );
That is still not correct, you need to make a real BSTR or use a wrapper class like _bstr_t
Well, it worked just fine, so I'm not convinced. Regardless, I am using CComBSTR for the real code, but I will keep that in mind for next time.
|
|
|
|
|
Hi,
I've got an XML file which I want to read in vb.NET.
I've tryied with the XMLDocument object but it's not enough for what I want to do.
So now I want to read it as a dataset but I need an XML Schema.
So my question, is it possible to build an XLT file from an XML file ?
Thx
Sybux
|
|
|
|
|
Open your XML data file in Studio, you said you're using VB .NET so I have to assume your using Visual Studio here as well ... anyway, right-click and select the Create Schema option; this will build an XSD file from the XML file. Once you've done that, and the XSD is open in the editor, you can make changes as you see fit.
When your done with your changes to the XSD, right-click, select the Generate DataSet. Go to the form you want to use the DataSet on and drop a DataSet component on the form. From the typed drop-down list, select your XSD file and you're ready to go.
Hope this helps(?)
D.
|
|
|
|