Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find an element-attribute pair, if given a line number?

Status
Not open for further replies.

mkuan

Programmer
Sep 19, 2001
69
CA
I've validated my XML file with a schema, and I know which lines (through the help of some Microsoft Visual Basic objects) are not conforming to the schema.

Is there a way to use the line number and attract the element-attribute value pairs that're giving me the errors?

For example,

99 ...
100 <person>
101 <surname>blah</surname>
102 <firstname>blahblah</firstname>
103 <age>x</age>
104 </person>
105 ...

Is there any facility that can help me to figure out it's the "age" attribute of "person" element with "blah" surname that's giving me the problem?

Thanks.

mink
 
xml is not "aware" of line numbers...

It doesn't care if you put a word on each line or all the tags in one line...

It reads it as a single line...

If you are using VB, you could use text manipulation to try to find the line...

If you are persistent to use XML methods, such as DOM, you could possibly return the "Object" such as the <person> tag, and it's children, but not the line number...

Is there any facility that can help me to figure out it's the "age" attribute of "person" element with "blah" surname that's giving me the problem?
What is the "problem" that are having with the xml?

You could posibly dump it through an XSL doc to force it into the form you desire...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
My problem is when my XML file (lets call it "final" file), which is generated from an XSLT file, does not contain the kind of information that's conforming to a schema provided by a 3rd party, I need to tell my user (through a report, Crystal Reports to be specific) which element's attribute is at fault so that the user can go into the system, correct the faulty data and rerun a process that generates a raw XML that gets translated by my XSLT file into my final XML file.
 
Again... What exactly is the problem?

Is it text where a number should be?
String too long?
...?

Most of this type of stuff can and should be handled in the XSL file...
You CAN build logic into XSL, it's not designed to be a dumb transformation tool, you can set it up like a program to fix all of the problems while it transforms...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top