|
I am confused on what you are attempting to do. I use a key to find nodes that need updating. If a key is not present, I find nodes via its parents or search for nodes that are missing certain child nodes or attributes. You may need to just determine if the structure of your XML document is right for what you are trying to do.
|
|
|
|
|
Imagine the following xml:
<foo>
<bar action="1"><element>xxx<element></bar>
<bar action="2"><element>yyy<element></bar>
<bar action="3"><element>zzz<element></bar>
</foo>
I query: /foo/bar[action='1']/element
I get "xxx" and I can update it. Good.
I query: /foo/bar[action='4']/element
Now, this node does not exist, so it should be created (and it's predecessor bar with the attribute action=4). foo exists, so nothing needs to be done for it.
Same aplies for /foo/bar[4]/element, just the attribute has to come from somewhere else (I can provide for this).
/foo/bar[5]/element should fail
This is not for a special xml file, but a generic solution, so it does not depend on any certain structure...
Does this make things a bit clearer?
-- modified at 16:53 Thursday 21st September, 2006
|
|
|
|
|
I cannot see your XML. Use "Ignore HTML tags in this message ...".
|
|
|
|
|
this should be better, now
|
|
|
|
|
I lose it right after "Now, this node does not exist, so it should be created". If you are trying to write generic code to act on any XML structure, you probably have to determine its schema beforehand.
|
|
|
|
|
Probably, looking up the schema is a good idea and I am not at all against it. The problem is, that mingling xpath with schema to create missing nodes via dom is something extremely complicated. I wouldn't even know where to start.
That's why I thought, that XUpdate would help me there, as it is an developed language for more or less this purpose. At least I am thinking it is. I just looked it up a few days ago and haven't found anything better since. But I have no idea, if XUpdate does not have any pitfalls I am not aware of, if the implementation, I found, is ok and most importantly, if there isn't some other, more straight forward way.
As for explaining my somewhat confusing (I admit) text:
I wrote a provider that allows me to update and delete nodes via xpath. That's something quite easy. Now I needed to insert nodes as well and as the xpath was something I already had in my classes, I tried to implement the insert as well via xpath. I failed at that and I am pretty sure that xpath just is not the right expression for the job.
Even though others at cp have tried something quite similar: http://www.codeproject.com/csharp/xpathstore.asp
So my examples have to be read with that bias: to use an xpath as an more or less equivalent to an sql insert statement.
I query: /foo/bar[action='4']/element
Now, this node does not exist, so it should be created (and it's predecessor bar with the attribute action=4). foo exists, so nothing needs to be done for it.
Same aplies for /foo/bar[4]/element, just the attribute has to come from somewhere else (I can provide for this).
/foo/bar[5]/element should fail (because there is no element bar[4] for it to be inserted after)
Thanks for sharing your thoughts!
Jan
|
|
|
|
|
How do i remove the last blank page?
I use page breaks in this one at the end of each page. So my last page is blank, always... How can i dump this page?
Thanks in advance
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Ummm this is the XML/XSL forum and your questions, as stated, do not appear to pertain to either one of them since neither have a "page".
Try this[^]
led mike
|
|
|
|
|
I'm converting my xml and xsl into pdf... SO since there is no pdf section i posted my question here....
I want to know if it is possible to remove the blank page, in my case the last page, from the resulting convertion from xml to pdf. Thank you in any case...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
NarutoFan#1 wrote: I'm converting my xml and xsl into pdf
Well I believe most people on Code Project are not psychic so unless you tell us "pdf" we don't know. So your question is a PDF question. How are you generating PDF from XML using XSL, are you using FO? I may know someone that I can ask if that is the case.
led mike
|
|
|
|
|
yes i'm using fop. i use page break after every tag called "TEST". This results in a blank page at the end since i have to close the "TEST" tag at the end. How do i remove this blank page if it is possible?
Thanks for your time...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
you should be able to do something like
<xsl:if test="not(position() = last())">
<!-- insert the page break FOP whatever -->
</xsl:if>
led mike
|
|
|
|
|
Thank you.
i'll try it now.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hi all,
How do you put a footer on each page sequence?
I have for each x amount of rows in a table a new page sequence, but what is the code snippet for inserting a footer...?
Thank you in advance...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
I'm pretty new to programming XML on .NET. I'm looking for best practices on constructing an XML document.
Do I have anything to gain by building an XML document with a StringBuilder and then converting it to an XmlDocument? Should I just create the document using the proper objects as I go along? Any other tips?
Thanks,
-- modified at 1:36 Wednesday 20th September, 2006
Edit: Upon further investigation, it looks like XmlTextWriter is what I'm after.
|
|
|
|
|
string PI= "type='text/xsl' href='Whatever.xsl'";
XmlTextWriter myXmlTextWriter = new XmlTextWriter("PATH.xml", null);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument();
myXmlTextWriter.WriteProcessingInstruction("xml-stylesheet", PI);
//Open tag.
myXmlTextWriter.WriteStartElement("TagName");
//Open Tag with Attribute.
myXmlTextWriter.WriteStartElement("TagName2",null);
myXmlTextWriter.WriteAttributeString("key", Convert.ToString(counter));
//StartTagAndEndTagWithValue
myXmlTextWriter.WriteElementString("TagName3","What You Want Between Tags");
//Close Tag. This One Closes the "TagName2".
myXmlTextWriter.WriteEndElement();
//Close Tag. This One Closes the "TagName".
myXmlTextWriter.WriteEndElement();
//Write the XML to file(Look at "PATH.xml" part at the top)and close the myXmlTextWriter
myXmlTextWriter.Flush();
myXmlTextWriter.Close();
Hope that it is of some help...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
|
Hello,
Could someone please refer me to an article, link, website to how this works. Or even better, explain to me the process from start to finsih. I just dont understand how this works completely.
Thanks
Steve-o H.
There are 10 kinds of people in this world... Those who understand binary and those who dont.
|
|
|
|
|
|
We have been bitten by severe memory leaks in our project.
While having a dry run of one of the components code. I came across the following. This looks like a sure shot memory leak to me. Because of the fact that we are not doing a VariantClear().
Please confirm.
<<
try
{
IXMLDOMSchemaCollection2Ptr m_pSchemaCache;
hr=m_pSchemaCache.CreateInstance(__uuidof(MSXML2::XMLSchemaCache60));
if (SUCCEEDED(hr))
{
hr=m_pSchemaCache->add(szNameSpace_in, szSchemaFilePath_in);
if (SUCCEEDED(hr))
{
VARIANT varValue;
varValue.vt = VT_DISPATCH;
varValue.pdispVal = m_pSchemaCache.GetInterfacePtr();
m_pSchemaCache.AddRef();
m_pDOMDoc->PutRefschemas(varValue);
}
else
{
this->m_errorCode=ERR_XML_DOC_SCHEMA_ADDITION_FAILED;
return FALSE;
}
}
else
{
this->m_errorCode=ERR_XML_DOC_SCHEMA_INSTANCE_CREATION_FAILED;
}
}
>>
Rajdeep
|
|
|
|
|
how can i pass xml nodes from a web service to a client.. as i m doin it in the normal way the way we pass strings but its giving a parser error and soap exception that value cannot be null
it gives an error at this line of code at the client:
xmlnode n=service.getnode();
bia ali
|
|
|
|
|
(string-length(normalize-space($Curnode/@*[position()=7])) != 0)*($MsgLength + 5)
What will the above expression return if normalize-space($Curnode/@*[position()=7]) returns "0020100101".
What will (string-length("0020100101")!=0) return true,1,or stringlength???
|
|
|
|
|
HI all
I have given a problem set in which i need to parse an xml document of size near about 1GB. In which the it should able to Parse/Load/Search the xml document in efficiently .
Now please anyone help me how to go for this means which are possible way and which is better PLease help me
|
|
|
|
|
|
Yes i have downloaded that project but its not related my query but i get the idea to read the fiel in chunk
|
|
|
|