473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Replacing Xml nodes based on validation results

I am using a XmlValidatingReader to validate an xml against a xsd schema.

What I would like to achieve is to "mark" each invalid node element with an
attribute. The resultant xml is then passed to the next stage of the
processing pipeline.

Therefore, an xml fragment such as:

<bk:book publisher="WROX">
<bk:title>XSLT Programmer's Reference</bk:title>
<bk:author>Michael Kay</bk:author>
<bk:publication-date>2001-04-30</bk:publication-date>
<bk:quantity>11</bk:quantity>
</bk:book>

<bk:book publisher="Addison Wesley">
<bk:title>Mythical Man Month</bk:title>
<bk:author>Frederick Brooks</bk:author>
<bk:quantity>AAAA</bk:quantity> <!-- Invalid as quantity should be
xs:integer -->
</bk:book>
should, after validation, becomes:

<bk:book publisher="WROX">
<bk:title>XSLT Programmer's Reference</bk:title>
<bk:author>Michael Kay</bk:author>
<bk:publication-date>2001-04-30</bk:publication-date>
<bk:quantity>11</bk:quantity>
</bk:book>

<bk:book publisher="Addison Wesley" valid="false">
<bk:title>Mythical Man Month</bk:title>
<bk:author>Frederick Brooks</bk:author>
<bk:quantity valid="false">AAAA</bk:quantity> <!-- Invalid as quantity
should be xs:integer -->
</bk:book>

My current thinking is to find a way to identify the offending node, and
then replace the invalid nodes in the XMLDocument. However, there seems to
be:
(i) no straightforward way to pick out invalid nodes with
XmlValidatingReader;
(ii) this requires passing through the xml doc multiple times.

Is there a better way?

Thanks,
Nick Wong
Nov 12 '05 #1
0 910

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rolf Kemper | last post by:
Dear Experts, I got stuck with the following problem and need your help. What I wnat to do is to get a set of distinct nodes. Before the distinct I have selected the multiple occourences...
3
by: Michael | last post by:
Hello, I am creating an XSL that is going to create a report from XML we recieve from another system. The XML would look like: <report> <page> <header1> <data1>asdf</data1>...
12
by: anonymous | last post by:
Hello, I need to replace this char  with another char. However I am not able to acieve this. I tried this but it doesnt work: str = str.Replace(chr(asc(194)), "") Can somebody help ?
6
by: DWrek | last post by:
Here is my problem. I have an XML document that is returned to me by a third party service. The XML document contains results for a search but only lists a maximum of 10 results. If there are any...
1
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The subset will be continous, so for example, if the...
2
by: James Fifth | last post by:
Hello and God Bless, I am stumped trying to get a simple xml database replacing certain data with other data programmatically. This is what my xml looks like. ...
2
by: SM | last post by:
Ok, this must be simple but the more i search the more i don't find. It's about SimpleXML and PHP. How to find non-existing nodes or nodes with no text My XML file looks a little bit like this:...
1
by: SM | last post by:
Ok, this must be simple but the more i search the more i don't find. It's about SimpleXML and PHP. How to find non-existing nodes or nodes with no text My XML file looks a little bit like this:...
1
by: TamusJRoyce | last post by:
I have xsl code which I was hoping could be used to replace one specific tag from an xhtml document and output another xhtml document. xsl has phenomenal potential in data replacing, but coming...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.