|
Alright, I got it working by using a param with my template and calling it recursively as required.
<xsl:template match="*">
<xsl:param name="Cont" select="."/>
<xsl:if test="@Null='false'">
<xsl:text>"</xsl:text><xsl:value-of select="substring-before(concat($Cont,'"'),'"')"/><xsl:text>"</xsl:text>
<xsl:if test="contains($Cont,'"')">
<xsl:apply-templates select=".">
<xsl:with-param name="Cont" select="substring-after($Cont,'"')"/>
</xsl:apply-templates>
</xsl:if>
</xsl:if>
</xsl:template>
Note the use of concat() in the call to substring-before().
Here the param is named "Cont" and you can think of it as meaning either "contents" or "continuance".
Given an initial value of: aaa "bbb" ccc
1) Output "aaa "
2) Recurse with bbb" ccc
3) Output "bbb"
4) Recurse with ccc
5) Output " ccc"
Result: "aaa ""bbb"" ccc"
I would appreciate any thoughts on this technique.
|
|
|
|
|
Hello,
My task is to convert race results like this to XML:
http://www.sportstats.ca\res1997\nord10k.htm
You can see that there are 1,948 race results. I need to create 1,948 xml elements. I would like to see XML data like this:
<Racer>
<Place>1</Place>
<ClockTime>29:41</ClockTime>
<PacePerK>2:59</PacePerK>
<BibNumber>1868</BibNumber>
<Name>Rachid TBAHI</Name>
<City>Sleepy Hollow</City>
<Prov>NY</Prov>
<CategoryPlace>1/213</CategoryPlace>
<GenderPlace>1/1216</GenderPlace>
<Category>Men 30-34</Category>
</Racer>
I've shown just the first entry, and would expect to see 1,947 more.
A few months ago, I wrote some C# code that would convert the URL above to the kind of XML I wanted. I noticed that the race results were all after a <pre> tag. I found that I had to use a C# regular expression to parse the race results. Creating one regular expression isn't so bad, but there is so much race results data, conforming to many different regular expressions, that this becomes a large project for me.
Recently, I found out about Dapper and thought it would be able to make this a manageable project. Their website is here: http://www.dapper.net/
I have tried unsuccessfully to create a Dapp that will do this. If you look at the source html for the sportstats URL, you will see that there isn't anything delineating the attributes I need to capture. It's not like a CSV file - it's more like an old fashioned mainframe fixed width file. I can't seem to define fields for the Dapp, as a result.
Any suggestions are most welcome!
Richard Rogers
|
|
|
|
|
Yeah, a regular expression. But I don't see why more than one would be required. (Not that I'm an expert.)
|
|
|
|
|
Hello,
The only reason more than one is required is because I need to import the following datasets:
http://www.sportstats.ca/res1997/nord10k.htm
http://www.sportstats.ca/res1997/sunny10.htm
http://www.sportstats.ca/res1997/ncm.htm
http://www.sportstats.ca/res1997/niaghalf.htm
http://www.sportstats.ca/res1997/niagmara.htm
http://www.sportstats.ca/res1997/ncmh.htm
http://www.sportstats.ca/res1997/rattle10.htm
http://www.sportstats.ca/res1997/xerox10.htm
http://www.sportstats.ca/res1997/sunny3.htm
http://www.sportstats.ca/res1997/ncm6k.htm
http://www.sportstats.ca/res1997/nordion.htm
http://www.sportstats.ca/res1998/nord5k.htm
http://www.sportstats.ca/res1998/ncm5k.htm
http://www.sportstats.ca/res1998/ncmmar.htm
http://www.sportstats.ca/res1998/ncmhalf.htm
http://www.sportstats.ca/res1998/sunny10.htm
http://www.sportstats.ca/res1998/reach5k.htm
http://www.sportstats.ca/res1998/kingbeat.htm
http://www.sportstats.ca/res1998/beat8k.htm
http://www.sportstats.ca/res1998/rattle10.htm
http://www.sportstats.ca/res1998/can10k.htm
http://www.sportstats.ca/res1998/grimhalf.htm
http://www.sportstats.ca/res1999/rsboiran.htm
http://www.sportstats.ca/res1999/nor10k1.htm
http://www.sportstats.ca/res1999/bay30k.htm
http://www.sportstats.ca/res1999/cimh.htm
http://www.sportstats.ca/res1999/sp10k.htm
http://www.sportstats.ca/res1999/cimm.htm
http://www.sportstats.ca/res1999/mara5.htm
http://www.sportstats.ca/res1999/rdkiran.htm
http://www.sportstats.ca/res1999/mara.htm
http://www.sportstats.ca/res1999/marah.htm
http://www.sportstats.ca/res2000/bay30k.htm
http://www.sportstats.ca/res2000/mds10k.htm
http://www.sportstats.ca/res2000/cimh.htm
http://www.sportstats.ca/res2000/ncmhalf.htm
http://www.sportstats.ca/res2000/ncm5k.htm
http://www.sportstats.ca/res2000/ncmmara.htm
http://www.sportstats.ca/res2000/cimm.htm
http://www.sportstats.ca/res2000/compu10.htm
http://www.sportstats.ca/res2000/casm.htm
http://www.sportstats.ca/res2000/gatorh.htm
http://www.sportstats.ca/res2001/nord10k.htm
http://www.sportstats.ca/res2001/bay30.htm
http://www.sportstats.ca/res2001/marahalf.htm
http://www.sportstats.ca/res2001/cimh.htm
http://www.sportstats.ca/res2001/mara5k.htm
http://www.sportstats.ca/res2001/mara.htm
http://www.sportstats.ca/res2001/cimm.htm
http://www.sportstats.ca/res2001/legacy5k.htm
http://www.sportstats.ca/res2001/pb5k.htm
http://www.sportstats.ca/res2001/casnm.htm
http://www.sportstats.ca/res2002/nord10k.htm
http://www.sportstats.ca/res2002/marah.htm
http://www.sportstats.ca/res2002/cimhalf.htm
http://www.sportstats.ca/res2002/scotiah.htm
http://www.sportstats.ca/res2002/bay30k.htm
http://www.sportstats.ca/res2002/mara.htm
http://www.sportstats.ca/res2002/mara5k.htm
http://www.sportstats.ca/res2002/cimmara.htm
http://www.sportstats.ca/res2002/pb5k.htm
http://www.sportstats.ca/res2002/casha.htm
http://www.sportstats.ca/res2003/marahm.htm
http://www.sportstats.ca/res2003/nord10k.htm
http://www.sportstats.ca/res2003/sp10k.htm
http://www.sportstats.ca/res2003/bay30.htm
http://www.sportstats.ca/res2003/timha.htm
http://www.sportstats.ca/res2003/scotiah.htm
http://www.sportstats.ca/res2003/mara5k.htm
http://www.sportstats.ca/res2003/marama.htm
http://www.sportstats.ca/res2003/timma.htm
http://www.sportstats.ca/res2003/casha.htm
http://www.sportstats.ca/res2004/marahm.htm
http://www.sportstats.ca/res2004/nordion1.htm
http://www.sportstats.ca/res2004/bay30.htm
http://www.sportstats.ca/res2004/torha.htm
http://www.sportstats.ca/res2004/marama.htm
http://www.sportstats.ca/res2004/nordion5.htm
http://www.sportstats.ca/res2004/torma.htm
http://www.sportstats.ca/res2004/missh.htm
http://www.sportstats.ca/res2004/casha.htm
http://www.sportstats.ca/res2004/missm.htm
http://www.sportstats.ca/res2005/runto.htm
http://www.sportstats.ca/res2005/marahm.htm
http://www.sportstats.ca/res2005/nordion1.htm
http://www.sportstats.ca/res2005/nordion5.htm
http://www.sportstats.ca/res2005/bay30.htm
http://www.sportstats.ca/res2005/marama.htm
http://www.sportstats.ca/res2005/torontoh.htm
http://www.sportstats.ca/res2005/missh.htm
http://www.sportstats.ca/res2005/torontom.htm
http://www.sportstats.ca/res2005/missm.htm
http://www.sportstats.ca/res2006/ncmhm.htm
http://www.sportstats.ca/res2006/ncm10.htm
http://www.sportstats.ca/res2006/ncm5k.htm
http://www.sportstats.ca/res2006/bay30.htm
http://www.sportstats.ca/res2006/missh.htm
http://www.sportstats.ca/res2006/torontoh.htm
http://www.sportstats.ca/res2006/ncmma.htm
http://www.sportstats.ca/res2006/missm.htm
http://www.sportstats.ca/res2006/torontom.htm
http://www.sportstats.ca/res2006/noseh.htm
So far, I've just looked at the first four or so, and I've got about four different "regex's".
Thanks for the confirmation!
Richard
|
|
|
|
|
Ah, one per dataset makes sense for very diverse datasets, but I looked at the first three, they seem pretty similar, so one general one might to do the trick.
Or, perhaps two;
One that helps examine the column headings and the dashed-line heading to dynamically create another one that's specific to that layout?
|
|
|
|
|
In the floowinf code I am expecting to append source node to end of destination node but?????
//I get the node here based on a source and destination ID.
XmlNode sxnode = dom.SelectSingleNode("//KeeperElement[ID = " + srcID + "]");
XmlNode dxnode = dom.SelectSingleNode("//KeeperElement[ID = " + destID + "]");
//This works fine proper nodes are obtained
//This append doesn't seem to be working for some reason
dxnode.AppendChild(sxnode.CloneNode(true));
//Also the remove not working
dom.RemoveChild(sxnode);
//When I reload file it shows no changes????
I have experience with ADO.Net do I need to do some sort of Update or AcceptChanges or something similar.
Thanks
Mike
Everybody gotta be somebody
|
|
|
|
|
Where did you save the file ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sorry,
I guess that would make a difference wouldn't it??
private void button2_Click(object sender, EventArgs e)
{
string str = Application.StartupPath + "\\KeeperOut.xml";
XmlTextWriter writer = new XmlTextWriter(str, Encoding.UTF8);
dom.WriteContentTo(writer);
writer.Flush();
writer.Close();
}
Thanks
Mike
You can do anything you want but you pay for everything you do!
|
|
|
|
|
If one of my Xml elements can potentially hold a large amount of data should I be using Element or CDATA. What is the difference between the two?
As an aside this is my 100 post...yipee?
Everybody gotta be somebody
|
|
|
|
|
Mike Hankey wrote: should I be using Element or CDATA
Since a CDATA section is nested inside an element the question should be: Should I use a CDATA section or not.
Mike Hankey wrote: What is the difference between the two?
A CDATA section is ignored by the parser but also applies some requirements on the data it holds. Take a look at this link XML CDATA[^].
Mike Hankey wrote: As an aside this is my 100 post
Congratulation
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Stefan,
Thanks for the information. CData it is, because the information may contain <> and other chars that may offend the parser.
Stefan Troschuetz wrote: Mike Hankey wrote:
As an aside this is my 100 post
Congratulation
I don't feel any different am I supposed to???
Everybody gotta be somebody
|
|
|
|
|
Helloo all
am using xmltextWriter to write node in xml file
XmltextWriter w=null
w=new Xmltextwriter(-----);
but the problem not in using writer
the problem is
I have listbox have this values
Level1
Level2
Level2
Level2
Level3
Level3
Level1
Level2
Level3
Level4
Level2
Level2
Level1
and soon on
i want to make witer get values for list and write it to xml
every level1 present base node(root node) and sublevels is subnodes
i want be unlimeted level
xml file show be appear like this
<root>
<level1>
<level2/>
<level2/>
<level2>
<level3/>
<level3/>
</level2>
</level1>
<level1>
<level2>
<level3>
<level4/>
</level3>
</level2>
</level2>
</level2>
</level1>
</root>
how can i do that
-- modified at 15:04 Wednesday 28th March, 2007
|
|
|
|
|
That seems pretty useless. There must be something you need after that right? What is it?
led mike
|
|
|
|
|
yes..its idea of my problem
can u help?
|
|
|
|
|
Instead of asking this question all over the CP forums and hoping that someone will do your work, you should start doing it yourself. If you encounter concrete problems while doing this, we'll be pleased to help you as best as we can, but nobody will spend his free time to do your work.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
I am new to Xml language,Can anybody tell what will be output of a xml parser???
Thanks in advance.
Siddharth
|
|
|
|
|
There are two types of XML Parser Standards
1) DOM Parser - produces an in memory tree structure of XmlNode objects
2) SAX Parser - fires events during parsing
led mike
|
|
|
|
|
I am using NDFD service for wether data : http://www.weather.gov/forecasts/xml/
First i got error : underlaying connection closed.
its resolved after i puts
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.HttpWebRequest webRequest =
(System.Net.HttpWebRequest)base.GetWebRequest(uri);
webRequest.ProtocolVersion = HttpVersion.Version10;
webRequest.KeepAlive = false;
return webRequest;
}
But now in some cases its gives me error:
Unable to read data from the transport connection. Connection closed.
Plz.. can any one help me on this?
I m using ASP.Net 2.0
With Regards,
Mayank Prajapati
MCP, MCTS
Sr. Software Engineer
JCTWeb India
www.jctweb.com
|
|
|
|
|
it is possible to set xsl dynamically to xml ??
i.e for the same xml document, under some conditions to
change the xsl for the xml document.
i am using asp.net(vb.net)
thanks
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
XSL is XML
led mike
|
|
|
|
|
for sure xsl is xml..........
but its a (xml based)style sheet for the xml documents
just like the css file to the html page.
anyway i found the answer.
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
I think the question actually should be "it is possible to set xsl dynamically for xml document??"...
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
anyone know a method for binding the contents [not only title and description, but also the link tag contents ] in an RSS feed in my webpage without navigating to the url when click for more info
i have worked with one xslt script at
http://www.codeproject.com/soap/reallymostsimplesyndctn.asp
but it support only the title and description alog with navigating to the link url with thr stuff
my reqrment is:
stuff in the should support my webpage style
how we can do it
can u plzzz help me
thanx in advance
will uplzz supply ur emailid too
thanx.................
RIYAM HUSSAIN
Sr.SOFTWARE DEVELOPER
INFORPARK, KOCHIN
|
|
|
|
|
Hi,
i am newbie for XML (also to .Net). i heard from some one that we can use XML for sending / retrieving the data from the database.
for this we have to use HTTPWebRequet. HTTPwebrequest send/recive the data in xml string format.
but how can we do this??
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
This magic is called XMLHttpRequest.
Google for it, you'll see a plethora of tutorials.
Best regards,
- Dmitry.
-------------------------
Don't worry, be happy )
|
|
|
|