|
MS le Roux wrote:
And yet you're referencing "C:\test\MyXSLFile.xsl"? Isn't that your seperate stylesheet?
I should have been clearer on that. The separate stylesheet does exist, but I don't see why I have to go to the trouble of loading it if it's already referenced in the XML. IE can pick it up directly from the link in the XML, so why not .NET?
However, from my research and some replies I've received, I don't think the XML classes in .NET can pick up an 'embedded' stylesheet like this, so I'll have to just load it separately anyway.
Just trying the lazy approach!
John.
www.silveronion.com[^]
|
|
|
|
|
I have a problem with a string containing the £ symbol (GB pounds). I can set the text of a child node using m_pXMLDoc->createTextNode(pszText) to a string containing £ chars ok, but if I try to reparse the xml using MSXML e.g. try displaying it in IE it complains about an invalid character i.e. the £. No problem I thought, I'll replace all £ chars with their escape sequence i.e. _163; (please ignore the _ - I had to include it to prevent HTML replacing the escape sequence with a £). All appears to work ok e.g. I can reparse the XML with MSXML and display it in IE, but MSXML has escaped my escape sequence i.e. instead of _163; the string contains £.
How can I stop MSXML doing this to my escape sequence? Or, how can I include a £ char in a string. I have to use MSXML 3, I can't use a DTD/Schema (don't ask) and I can't use a CDATA section (again, don't ask). Any help/advice would be much appreciated.
Gavin
|
|
|
|
|
this is a classic problem - you will run into it all the time.
the important point is that £ is resolved by the parser, i.e. by the time you get a look in it has been converted to its character.
generally these issues are caused by the encoding attribute that is specified at the top of your xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
People have a nasty habit of sticking any old encoding in here, without considering what encoding they are using - for example different versions of windows (95, 98, NT) have used different encoding schemes.
Also be careful if you use XSLT - you have to tell it how to output it
<xsl:output encoding="iso-8859-1"/> .
Otherwise you will end up in a world of pain
my general advice is to always replace any characters with values below 32 and above 128 with a tag - this allows you to handle the problem. consider using a <character code="163"/> tag, this way you can do what you like.
hope this helps.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hi,
I have a problem with streaming XML. I have created an aspx which return me an xml file format (Type text/xml, Encoding.UTF8). Also now, I try to read this stream in the XmlTextReader but I receive an Error Message when I parse it. And of course, I don't understand that.
Could you help me?
It is a bit urgent....
Thanks a lot
Code Source
XmlTextReader XR = new XmlTextReader(Server.MapPath("GenerateXmlTreeView.aspx"));
while(!XR.EOF){
XR.ReadElementString(); //Here Thrown exception
}
Sr.Close();
When I run may aspx
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: The '%' character, hexadecimal value 0x25, cannot begin a name. Line 1, position 2.
Source Error:
Source XML:
<?xml version="1.0" encoding="utf-8"?>
<treeview title="Licenses Tool">
<custom-parameters>
<param name="shift-width" value="15" />
<param name="img-directory" value="images/" />
</custom-parameters>
<folder title="1999" url="49">
<folder title="Gis Eastern" url="39">
<leaf title="Azerbaijan" url="37" reg="N" />
<leaf title="Belarus" url="20" reg="N" />
<leaf title="Bulgaria" url="21" reg="N" />
<leaf title="Croatia" url="22" reg="N" />
<leaf title="Czech Republic" url="23" reg="N" />
<leaf title="Estonia" url="24" reg="N" />
<leaf title="Hungary" url="25" reg="N" />
<leaf title="Kazakhstan" url="26" reg="N" />
<leaf title="Latvia/Lettonia" url="27" reg="N" />
<leaf title="Lithuania" url="28" reg="N" />
<leaf title="Poland" url="29" reg="N" />
<leaf title="Rumania" url="30" reg="N" />
<leaf title="Russia" url="31" reg="N" />
<leaf title="Slovakia" url="32" reg="N" />
<leaf title="Slovenia" url="33" reg="N" />
<leaf title="Turkey 1" url="38" reg="N" />
<leaf tit
-=zoltx=-
|
|
|
|
|
this wont work because you are reading the source for the apsx, i.e. you are getting back the <% aspx stuff %>
you need to load the xml from using a uri, not from the file system
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hi all,
I have the following sample XML file
<ROOT>
<STRING id="Some string \"some with in quotes\" other\'s with apostrophee %s">
<LOCALE>Locale Equivalent of above id string</LOCALE>
<FILE line="321">myheader.h</FILE>
</STRING>
<!-- Many string tags to follow-->
<?ROOT>
The "id" contaims string constants extrcted out of C/C++ source code. and the value contains "LOCALE" contains locale equivalent string.
I load the xml document document using the XmDocument.Load( fileName) in C#.
Sample code
string idvalue = "Some string \"some with in quotes\" other\'s with apostrophee %s";
string path = "/ROOT?STRING[@id = \"" + idvalue + "\"]/LOCALE"; // so as to get the text between LOCALE tag
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
string str = doc.DocumentElement.SelectSingleNode(path).InnerXml;
Howvever the the statement throws an exception because the quotes in the path string is not escaped in XML. SelectSingleNode() takes an XPATH expression. How to escape the quotes in an XPATH expression so that the last statement works correctly.
The last expression is a problem only when their is a " in id attribute, since the attribute value is enclosed in quotes in Xpath. for id attribute values with no quotes takes me correctly to the text betwen LOCALE tag
I tried encoding the " in variable idvalue to " in XPATH, still no success
The XML is successfully validated internally aginst a DTD.
The XML file contains ", ', &, <, > in their encoded form.
Any solutions to offer
Regards,
Ajith
Regards,
Ajith
|
|
|
|
|
Its seems the XML contents I posted previously has not come.
Here I am posting it as a comment
<br />
--<ROOT><STRING id="\"Hello\'s World\""><LOCALE>Locale specific text equivalent value of id</LOCALE></STRING></ROOT><br />
--
Regards,
Ajith
|
|
|
|
|
Just go back and edit your message. Make sure to check the display message as-is (no HTML).
<MyXML> Here is text </MyXML>
<b><i>"Sig"</i></b>
|
|
|
|
|
Its seems the XML contents I posted previously has not come.
Here I am posting it as a comment
Regards,
Ajith
|
|
|
|
|
Hi all,
I have the following sample XML file
<root>
<string id="%s\" hello\'s="" world\""="">
<locale>Locale Equivalent of above id string
I load the xml document document using the XmDocument.Load( fileName) in C#.
Sample code
string idvalue = "%s\"Hello\'s World\"";
string path = "/ROOT?STRING[@id = \"" + idvalue + "\"]/LOCALE"; // so as to get the text between LOCALE tag
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
string str = doc.DocumentElement.SelectSingleNode(path).InnerXml;
Howvever the the statement throws an exception because the quotes in the path string is not escaped in XML. SelectSingleNode() takes an XPATH expression. How to escape the quotes in an XPATH expression so that the last statement works correctly.
The last expression is a problem only when their is a " in id attribute, since the attribute value is enclosed in quotes in Xpath. for id attribute values with no quotes takes me correctly to the text betwen LOCALE tag
The XML is successfully validated internally aginst a DTD.
The XML file contains ", ', &, <, > in their encoded form.
Any solutions to offer
Regards,
Ajith
|
|
|
|
|
I got a xml file, sth. like this:
- <rptindex>
<title>AppAnalyzer
<description>This report displays entries in the task log. Each entry in the report represents the end of a report task.
<subject>
<author>NetIQ
<category>Servers
<component>Servers
<company>
<document>default.htm
<datasource>localhost\AppAnEx_current
<createddate>4/2/2003 4:50:25 PM
<hasdata>True
<expires>60
Now, I want to modify this file and take out the first line " " and save it back to this file. What's the easiest way to do this (a dos command or I have to write a tool)?
|
|
|
|
|
Hello,
I have an XmlNodeList with attributes and and text values. I am looking for a way to create a function that can return a value from reading a nodelist by specifiying the attribute name. For example, string a = FieldByName("acct") would result in 12345 being returned.
<fields>
<field name="acct">12345</field>
<field name="company">ACME Inc</field>
<field name="city">Dallas</field>
<field name="state">TX</field>
</fields>
Any help would be greatly appreciated.
Thank you.
|
|
|
|
|
After having read up on XSD I've come to the conclusion that it should be possible to "compilers" for XML documents. With compiling I mean reading the XML input and turn it into raw & ready to use data.
To clarify what I mean:
<people>
<person>
<name>Jörgen</name>
<age>27</age>
</person>
<person>
<name>Mr Who</name>
<age>123</age>
</person>
</people> This particular document should be representable using a C++ structure like this:
struct person {
std::string name;
int age;
};
typedef std::list<person> people; This can all be done using various techniques such as DOM or SAX, and some hand written code.
However, writing stuff like this for large and complex XML documents is a tedious task, and possibly quite error prone. Processing DOM trees is a simple, but lazy way to deal with it. DOM trees are bloated and contains a lot of information which is basically redundant information for the application.
I am sure it is possible to write a parser generator which
- reads XSD definitions
- generates C++ structures based on XSD information
- generates a SAX based parser/compiler which instantiates the C++ structures and populates them with data from the XML document
I'm guessing such code would be quite non-bloated and fast (at least compared to DOM). Does anybody know if this has been done?
--
Tune your mind, reach inside, peel away
Touch, Taste, Feel, Saturation
|
|
|
|
|
Just some comments.
I am not sure if exactly what you ask for has been implemented but code to create XSD from XML files and build entry forms exist so the basics are there. Now I have a question. You still need to know the structure to program against so maybe I am just missing some clever implementation but you still have to create code to work with that specific structure correct? and since it has all of the information it is not drastically different than the DOM model. Given this is true code like Kristen Wegner's PUGXML[^] is not that much different from what I hear you asking for. Yes you still step down through the DOM tree but you would in your classes also. You are trading the C++ class overhead for the overhead of the XML file in memory. IMhO gaining familiarity with a DOM or SAX implementation would be more profitable than having to relearn each custom generated class. Am I missing your intent?
""
|
|
|
|
|
Michael A. Barnhart wrote:
You still need to know the structure to program against
Yes, this is correct. But if you do have a schema for the data, that is not really a problem is it? The schema is a beautiful thing: it has structure and it has types - all of them transferable into C++.
Michael A. Barnhart wrote:
and since it has all of the information it is not drastically different than the DOM model.
The DOM model must maintain a lot of unnecessary information which I am not interested in. At least if you take into account that I already know structure and datattypes. If I take a look at IXMLDOMNode in MSXML 4 for instance, I find that most of its properties are totally unneccesary if I already know the structure and type information of the data to begin with! Names for instance, are maintained by the compiler (names of struct s and members), "other node references" such as first, last, parent, are not interesting - I already know the structure. Not to mention the underlying XML text code!
I guess what I want to do is pretty much what template programmers want to do: bind as much information as possible at compile time rather than runtime.
Michael A. Barnhart wrote:
You are trading the C++ class overhead for the overhead of the XML file in memory.
Well, compared to a DOM document, I am sure I'd have huge advantages. I'd have a "distilled" collection of data, while the DOM tree would have a very verbose collection of data + a text copy of the entire XML document file in memory.
Michael A. Barnhart wrote:
IMhO gaining familiarity with a DOM or SAX implementation would be more profitable than having to relearn each custom generated class. Am I missing your intent?
I'm basically saying that DOM and SAX are crude interfaces for dealing with entire documents if you don't want to do fancy operations such as transformations. If you are only interested in the data, then C++ structures and STL datatypes and structures would give you a very nice interface - it would model the data 1:1 basically.
A DOM interface models a general tree, which is also untyped. Sure, you've had the DOM tree validated against a XSD, but you'll still have to do conversions etc.
In essence, I just want a faster and more static version of DOM.
--
Tune your mind, reach inside, peel away
Touch, Taste, Feel, Saturation
|
|
|
|
|
Jörgen Sigvardsson wrote:
In essence, I just want a faster and more static version of DOM.
OK, and I see the benefit of doing this if it is something you run all of the time. Much of what I have to work with is not as stable as one would like. So flexibility is my biggest driver. I do not see the typical developer doing this a lot of the time. You would create a class and struct for the needed data and have a XML import export functions in it that would be SAX event driven if anything but small files are handled. So you save a few hours when adding a new data structure. How often do you expect to add new data structures? Yes if one person takes the weeks to built it, many can benefit. To truly cover all of the schema variations could be a bit taxing on someone.
""
|
|
|
|
|
If you mean something like xsd.exe[^] that comes with Visual Studio.NET, or JAXB[^], you're out of luck currently as far as free tools go (of course, xsd.exe isn't free, but you may well have VS.NET anyway...). However, xsd does say that it'll support anything that implements System.CodeDom.Compiler.CodeDomProvider, which C++ may do when Visual Studio 2003 arrives. Of course, it would still only be Managed C++....
Other alternatives (all for Java ) are Castor[^], Jaxme[^] and Jibx[^]
Of course, if you've got money to spend, there are C++ options like xmlspy[^] and RogueWave's XML Object Link[^]
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Thank you very much for this information! I was beginning to sketch a little on an implementation very much like RogueWaves XML Object Link.
I think I will look into this CodeDom-stuff. Maybe I could write my own classes to generate "pure" C++. Looks like I can forget that.
--
Tune your mind, reach inside, peel away
Touch, Taste, Feel, Saturation
|
|
|
|
|
XML Data Binding tools provide this, but you need to describe your xml in a schema (xsd/xdr/dtd).
http://www.rpbourret.com/xml/XMLDataBinding.htm lists available tools.
I use the wizard from Liquid Technologies:
http://www.liquid-technologies.com/Products/LXDBWizard.htm
|
|
|
|
|
I want to be able to concatenate several XML files together, and I can't find anything on W3C.org that says xml has an "include" tag. Does it? Am I blind? Or am I screwed?
Conversely, the reason I need this is because the stupid XmlDataDocument.Load method can't be called more than once. It requires a blank document, and there is no Append or similar function.
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 Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
No you are not blind. There was an include processor command but it was rather unsecure do a google on "Xml eXternal Entity" and was removed if my memory is working tonight.
Take a look at XInclude (candidate recomendations) and XLink (recomendation)
XInclude[^]
XLink[^]
""
|
|
|
|
|
Have a look at the ImportNode and AppendChild methods. Something like this should work:
XmlDataDocument doc1 = LoadDoc1();
XmlDataDocument doc2 = LoadDoc2();
foreach(XmlNode source in doc2.DocumentElement.ChildNodes)
doc1.DocumentElement.AppendChild(doc1.ImportNode(source, true));
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hi,
I have many entries in my XML and I would like to search for one in particular (the one the user wants) but not show it, just take that entry and check an element in it, how would this be done.
Ex:
<?xml version="1.0" encoding="UTF-8"?>
<Airports>
<Airport>
<ICAO>KABE</ICAO>
<Name>Allentown Intl PA</Name>
<Lat>40.652364</Lat>
<Long>-75.440403</Long>
</Airport>
<Airport>
<ICAO>KABI</ICAO>
<Name>Abilene Reg. TX</Name>
<Lat>32.411319</Lat>
<Long>-99.681897</Long>
</Airport>
I want to look up KABE and put its Long value in a double. (BTW, I have no schema for this file, only the XML, would a schema be helpfull here?)
Thanks...
// JS Paquet
cout << "Thank you all" << endl;
|
|
|
|
|
Try something like:
XmlNode node = doc.SelectSingleNode("/Airports/Airport[ICAO='KABE']/Long");
double lon = double.Parse(node.InnerText);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hello,
I have one element named LoadConfig. It has one attribute named 'Type'. The attribute 'Type' can have two values('PreDefined' or 'UserDefined'). If attribute value is 'PreDefined', LoadConfig element can have 3 child elements. If attribute value is 'UserDefined' LoadConfig element can have any type xml nodes as its childnodes. Can anybody explain how to make schema for this.
Thanks,
Chito
|
|
|
|
|