|
Hi guys,
I am validating my xml with schema.
the validation rotine return line number and line position, if the validation fails.
given the line number,line position i can get to node that fails the validation test using IXmlLineInfo.
see http://msdn2.microsoft.com/en-us/library/system.xml.ixmllineinfo.aspx
I need to build the xpath from that node
any ideas are helpfull
Thanks
Mustafa
http://www.hostukdomain.com
|
|
|
|
|
What I would suggest is that you take advantage of the position() function. The problem you'll be up against is that you may have a lot of similar nodes. So, if you have XML that looks like this:
<Foo>
<Bar>9</Bar>
<Bar>7</Bar>
<Bar>asd</Bar>
</Foo>
Maybe the asd is the part that fails the schema, so you need an XPath that gets to the third Bar node. You could write something like this:
/Foo/Bar[position()=3]
If you know the node that fails, you should be able to get an XPath to it.
Logifusion[^]
|
|
|
|
|
<Thanks Dustin
Indeed a very similar position coz i could have multiple nodes of same name.
I am thinking abt ur solution but during runtime i might not know the node position that could fail.
sample xml
<root>
<level1>
<nest11</nest1>
<nest2>2</nest2>
</level1>
<level2>
<nest1>1</nest1>
<nest2>some bad value</nest2><!-- say this node fails -->
</level2>
</root>
then i should run some rotine to return /root/level2/nest2
i will try position() function but if can throw more light will be helpfull.
cheers
Mustafa
http://www.hostukdomain.com[^]
-- modified at 11:30 Friday 7th July, 2006
|
|
|
|
|
Well, first you have to change the <'s and >'s to <'s and >'s so I can see your XML. But I would say if you have the actual XmlNode object representing the node that has the error, you could get its parent. With the parent node, search through its child nodes to find the current node you're holding. You should be able to get an index. Add 1 to it and get the position.
Logifusion[^]
|
|
|
|
|
hope you can see the xml now
I will try what you have suggested... just to let you know i am using XmlValidatingReader to derive the IXmlLineInfo which has the lineinfo
I will try and see if I could use XPathDocument or XMLDataDocument but not sure if i can get the node using the lineinfo
will try and post back..
all have nice weekend
cheers
Mustafa
http://www.hostukdomain.com[^]
-- modified at 12:35 Friday 7th July, 2006
|
|
|
|
|
Hi All,
I'm trying to get my flow right with the xml and xsl files...
is it possible to do the following...
my xml file looks like this...
<ClientLookUp>
<Title>
<Heading>WhatEver</Heading>
<Date>TodayOrWhatEver</Date>
</Title>
<TableEntries key="0">
<ClientName>exampleJohn</ClientName>
<ClientSurname>exampleSmith</ClientSurname>
<ClientAge>example21</ClientAge>
<ClientID>example8501014341988</ClientID>
<ClientType>WhateEver</ClientType>
<ClientBday>example01January</ClientBday>
<ClientTelH>example903-0201</ClientTelH>
<ClientFaxH>example903-0202</ClientFaxH>
<ClientEmailH>exampleJohn@Home.co.za</ClientEmailH>
<ClientTelW>example903-0203</ClientTelW>
<ClientFaxW>example903-0204</ClientFaxW>
<ClientEmailW>exampleJohn@Work.co.za</ClientEmailW>
<ClientCell>example903-0205</ClientCell>
</TableEntries>
<TableEntries key="1">
<ClientName>exampleSam</ClientName>
<ClientSurname>exampleLooker</ClientSurname>
<ClientAge>example22</ClientAge>
<ClientID>example8501014341982</ClientID>
<ClientType>WhateEver</ClientType>
<ClientBday>example01January</ClientBday>
<ClientTelH>example903-0301</ClientTelH>
<ClientFaxH>example903-0302</ClientFaxH>
<ClientEmailH>exampleSam@Home.co.za</ClientEmailH>
<ClientTelW>example903-0303</ClientTelW>
<ClientFaxW>example903-0304</ClientFaxW>
<ClientEmailW>exampleSam@Work.co.za</ClientEmailW>
<ClientCell>example903-0305</ClientCell>
</TableEntries>
</ClientLookUp>
is it possible to, Depending on whitch of these tags are created, that they could follow up on each other whith spaces between them?
He who laughs last...
-- modified at 4:48 Friday 7th July, 2006
|
|
|
|
|
Like for instance....
if only the ClientName and the ClientTelH was selected in my program and i created the ClientName and the ClientTelH tags only...
i want it to display like this...
exampleJohn 903-0201
exampleSam 903-0301
better yet
can i create a tabel and the cell only as tags are created? to be able to align the output?
for instance...
exampleJohn 903-0201
exampleSam 903-0301
any help whould be greatly appreciated.
Thank you in advance...
He who laughs last...
|
|
|
|
|
Use
<xsl:for-each select="//ClientLookUp/TableEntries">
to iterate thru each entry and
use
<xsl:if test="">
to find out if the node exist then dump the data as you want
Jup
-- modified at 11:03 Friday 7th July, 2006
|
|
|
|
|
Can you modify your post so that you change all the <'s to <'s and so forth? Nobody can see what's in your post.
Logifusion[^]
|
|
|
|
|
|
I need replace node value with multiple line text in a Word XML Document with ASP.net 2.0 application. I tried to use InnerText method in XMLNode object but it failed:
oNode.InnerText = “Address line 1 “ & chr(13) & “ Address Line 2 “ & chr(13) & “ City, State: 12345”
Output on the document: “Address line 1 Address Line 2 City, State: 12345”. I also tried the following:
oNode.InnerText = “<w:p><w:t>Address line 1 <w:p><w:t> Address Line 2 <w:p><w:t> City, State: 12345”
Output on the document: “<w:p><w:t>Address line 1 <w:p><w:t> Address Line 2 <w:p><w:t> City, State: 12345”
Any help is appreciated.
|
|
|
|
|
Maybe try these characters for a newline: 

Logifusion[^]
|
|
|
|
|
Where can I find the typed dataset for MS Project XML files?
Iv’e tried to create my own but when trying to read an MS Project XML-file like this:
MSProjectDataSet dataset = new MSProjectDataSet();<br />
dataset.ReadXML("savedXMLfileFromProject.xml");
I get different exceptions.
All tips in this topic are welcomed!!
_____________________________
...and justice for all
APe
|
|
|
|
|
Hi all,
How do you use the if statements in a stylesheet?
The thing i want to do is to check if a tag in the xml file exists and if it does'nt, then combine 2 cells.
i think it should be something like this...
<xsl:if (does the "test=" part here mean i have to insert the "Check if the tag exists?" statement)>
He who laughs last...
|
|
|
|
|
<code><xsl:if test="*[self::elementName]"> or
<xsl:if test="*[name() = 'elementName']"></code>
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
-- modified at 11:24 Tuesday 4th July, 2006
|
|
|
|
|
Thank you
He who laughs last...
|
|
|
|
|
hi
I am using MS XML 4.0 and VC++.
When I tried to load the XML file with XSD referecvv , my XPAth queries are returning NULL .
What could be reason?
Please help me.
thanks in advance
|
|
|
|
|
Hi,
I'm looking to search through child nodes, and then capture the value of the node and also that of the parent node. For example, the user enters details into a field, which then gets checked against the child node, if matched then it gets the value of that node and also the parent value. Which then will be populated into a treeView
I'm trying to use XMLPathNavigator and it doesn't appear to be working. Any ideas? Or other ways to attempt this. I'm using c#.net 2005 to do this.
It sounds extremely easy, but just can't get it to work.
Cheers... Dan
Cheers.. Dan
|
|
|
|
|
Perform the search in XPathDocument or XmlDocument by using SelectSingleNode method. When element is found it is easy to navigate back to the parent node (ParentNode property).
Best regards,
-----------
Igor Sukhovhttp://sukhov.net
|
|
|
|
|
Hi,
in xslt i have written an template where in i have created text box(txtbx2) and binded a value as follows:
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 465px; POSITION: absolute; TOP: 151px" runat="server">
<Columns>
<asp:TemplateColumn HeaderText="col1">
<ItemTemplate>
<asp:TextBox ID="txtbx2" Runat="server" text='<%# DataBinder.Eval(Container,"DataItem.BookNum") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</xsl:template>
</xsl:stylesheet>
but on running it i get an exception that scripts cant be run.Pls help me out
|
|
|
|
|
I am entering some of my data straight into an XML doc and like the nodes to display like the top form. But calling XmlDocument.Save(filepath) changes them to the 2nd form. Is there any way to keep the formating or write out the elements? Or do you know of an Xml Editor to help me?
<KICategory>
<Name>TIME</Name>
<Type>GENERAL</Type>
<KnownItems Add="true">
<BaseKI><Name>FULL_DATE</Name></BaseKI>
<BaseKI><Name>MONTH_DAY</Name></BaseKI>
<BaseKI><Name>MONTH_YEAR</Name></BaseKI>
<BaseKI><Name>YEAR</Name></BaseKI>
</KnownItems>
</KICategory>
<KICategory>
<Name>TIME</Name>
<Type>GENERAL</Type>
<KnownItems Add="true">
<BaseKI>
<Name>FULL_DATE</Name>
</BaseKI>
<BaseKI>
<Name>MONTH_DAY</Name>
</BaseKI>
<BaseKI>
<Name>MONTH_YEAR</Name>
</BaseKI>
<BaseKI>
<Name>YEAR</Name>
</BaseKI>
</KnownItems>
</KICategory>
|
|
|
|
|
HI ,
I have an xml file in my application folder
when i run the application, i wanna load the contents of the xml file into text box.I am using C#.net .how do i do??
.
please help
Thanks
Jiny
-- modified at 1:18 Friday 30th June, 2006
|
|
|
|
|
hi,
i hope it is help
<br />
<?xml version="1.0" encoding="UTF-8" ?><br />
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ><br />
<xsl:template match="/"><br />
<textarea style="width:100%;border:0;overflow:visible"><xsl:value-of select="//doc"/></textarea><br />
</xsl:template><br />
</xsl:stylesheet>
regards
|
|
|
|
|
Try this in your code-behind file:
string strPath = "xmlFolder/MyXMLFile.xml";
StreamReader objSR = new StreamReader(Server.MapPath(strPath), Encoding.Default);
string strSRcontent = objSR.ReadToEnd();
Textbox1.Text = strSRcontent;
--Dimple
|
|
|
|
|
Good Morning All,
I have a wierd problem... I have these "-&-#xD-;-&-#-xA-" (I inserted the -'s because it wasnt showing up on this post); characters showing up all through my XML transfomration where there is a line feed or a return... I have used this, (not sure it helps) and I still get them.<xsl:strip-space elements="*"> Is there anyway to get ride of these characters (without a regular expression on the transformed XML) ? It is screwing up my embedded JavaScript...
System.IO.StringWriter swTransformedXML = new System.IO.StringWriter();
trainingXSL.Transform(xmlTransformDoc, xslArguments, swTransformedXML, new System.Xml.XmlUrlResolver());
The swTransformedXML contains the junk characters...
Brandon
-- modified at 13:35 Thursday 29th June, 2006
|
|
|
|