|
What is setting $subtitle?
You have an XML document which you are processing the xslt against, then you can apply the XPath query that is in the select statement against the xml, passing in the relevant item for $subtitle. This is the quickest and easiest way to get the value out. I already intimated that the XPath would be a better approach for this problem.
The following XPath solves your problem:
private int GetValue(string xmlFile, string title)
{
XPathDocument doc = new XPathDocument(xmlFile);
XPathNavigator nav = doc.CreateNavigator();
XPathExpression expr = nav.Compile(string.Format(
"ceiling(count(//Category[Title='{0}']/Category1/MetaData))", title);
object obj = nav.Evaluate(expr);
int output = 0;
if (obj != null)
{
output = Convert.ToInt32(obj);
}
return output;
}
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Abubakar
Did the sample I suggested solve your problem? If so, it would be nice for you to let people know.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I am Sorry, I havn't check it yet, I hope I will check later of the day then I will inform every one.
Thanks,
Abubakar
|
|
|
|
|
Hi Friends,
First of all Sorry for late I was little busy with other projects. I tried the code which you gave me to use variables in .cs file defined in xsl file but still it is not working. it is giving 0. I used the following code please have a nice look on it and give me some suggestions.
OUTPUT of following code is 0.
string URL = Server.MapPath(Request.ApplicationPath + "/xsl/Videos.xsl");
XPathDocument doc = new XPathDocument(URL);
XPathNavigator nav = doc.CreateNavigator();
XPathExpression expr = nav.Compile(string.Format("ceiling(count(.//Category[Title='$subtitle']/Category/MetaData))"));
object obj = nav.Evaluate(expr);
int output = 0;
if (obj != null)
{
Response.Write("Something : " + Convert.ToInt32(obj));
}
Regards,
Abubakar
|
|
|
|
|
First of all, you are loading in the XSL file and not the XML file. Try using the code I suggested against the XML file. As I stated before, you should be using the XML as the source - you are using XSL for transformation only.
Secondly, when you do it, you would want to replace $subtitle with the value of the variable that you want to select - take a look back at my code sample to see how to do it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
HI,
First I tried with your code friend, but it was giving error with 'title'
Second and most important one I don't have any phiysical XML file I am using webservice to fetch data. I am using xsl only to format it. data is infact coming from database exists in another country. I am only using web service method. Hope you will understand my situation now. If you have solution for it please let me know.
Regards,
Abubakar
|
|
|
|
|
Abubakarsb wrote: First I tried with your code friend, but it was giving error with 'title'
Second and most important one I don't have any phiysical XML file I am using webservice to fetch data. I am using xsl only to format it. data is infact coming from database exists in another country. I am only using web service method. Hope you will understand my situation now.
Errm - you do have an XML file even if it's not physically situated on your hard disk. You don't have to load XML directly from a file, you can load it in from a stream. All you have to do is use the XPathDocument constructor that loads a stream.
The principal still holds true. You have an XML file - where you get it doesn't matter - you use XPath to parse it and extract the information. Just use the same value for title that you were going to use in the XSL parameter.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I am sorry friend, as I am a new bird here in xsl and c# I really don't understand what u want to say It will be really nice If you give me some sample for it I am going to send you my code in .cs file and xsl file; Please modify them and send me right ones. It will be really kind to me.
Code in .cs File;
string URL = Server.MapPath(Request.ApplicationPath + "/xsl/Videos.xsl");
XPathDocument doc = new XPathDocument(URL);
XPathNavigator nav = doc.CreateNavigator();
XPathExpression expr = nav.Compile(string.Format("ceiling(count(.//Category[Title='$subtitle']/Category/MetaData))"));
object obj = nav.Evaluate(expr);
int output = 0;
if (obj != null)
{
Response.Write("Something : " + Convert.ToInt32(obj));
}
Code in xsl File;
<xsl:variable name="size" select="ceiling(count(.//Category[Title=$subtitle]/Category/MetaData))"/>
Regards,
Abubakar
|
|
|
|
|
No. That's not what you want to do. You have the XML file that you are going to transform - that's what goes into XPathDocument. So if you had the following:
Stream xmlStream = GetStreamFromDataSource();
You would then declare XPathDocument like this:
XPathDocument doc = new XPathDocument(xmlStream);
Then, as I've stated so many times, your XPathExpression will not use $subtitle. This is an XSL parameter. If you were looking for books with the title I Claudius, then you would replace this with:
XPathExpression expr = nav.Compile(string.Format("ceiling(count(.//Category[Title='{0}']/Category/MetaData))", "I Claudius"));
This replaces the {0} placeholder with the text I Claudius.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks a lot friend now It is giving error on this line
Stream xmlStream = GetStreamFromDataSource();
I am using following code to get values from webservice;
il.co.besttv.mfw32.Front fm = new il.co.besttv.mfw32.Front();
XmlNode resultNode = fm.fetchCategoryFrontXml(customId, guiId, priceId, vodTreeId);
Regards,
Abubakar
|
|
|
|
|
Hi Pete O'Hanlon,
You didn't reply me yet about this line of code
Stream xmlStream = GetStreamFromDataSource();
This is giving a complie time error.
Regards,
|
|
|
|
|
Excuse me, but I give my time freely to this site and don't have time to waste on people who don't want to help themselves. If you think about the code sample for more than a couple of seconds you will see that it can't possibly know about how to get your XML stream, which is why I put a stub method here (cunningly called GetStreamFromDataSource).
I'm sorry, but you are going to have to actually do some work for yourself and figure this one out yourself. I have spent more time on your problem than I normally would have and I've provided code samples for you to look at. At some point you have to engage your brain and actually do some work for yourself.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I am really sorry for wasting your time. by the way I worked on it 3 hours not couple of seconds. Thanks for comments,
Regards,
Abubakar
|
|
|
|
|
Hi all,
I am working on C# windows applcation..
I want a componet, which will generates the waveform as output..
Hope u understood my requirement please help me as soon as possible
i'd surfed alot, and with no result..plz help
pashi
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
|
Hi John,
Thnx alot for ut valuable Response,
But Please look at my Requirement Below,
John, My requirement is,
see i have a laser which emits radiation with some frequency, i need to catch that lasers output and I HAVE TO TAKE THIS AS INPUT TO MY COMPONENT...AAnd i have to process this(i've algorithms to process) and MY OUTPUT(i mean my components output) Should be capable of giving output in DIFFERNNT TYPE OF WAVEFORMS(Like sign wave,CW RAMp etc..(ofcource only one at a time))
Thnx in advance,
pashi
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
I'm really going to have to change my sig. My names Pete not John. John is the name of somebody that I'm quoting.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
oh! sorry mr.pete
i was mistraken.
k about requirement...
did u found/know any tool which can help me
all it should is just -it should be capable of taking inputs and process them in to DIFFERENT KINDS OF WAVEFORMS>....
thnx in advance
pashi
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
There's always this one from National Instruments. http://ni.com/mstudio/[^] It's expensive, but it does seem to cover what you need.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
i want to view avidio via windows media player i used the media player class
and write this
m.FileName = "Goda-Masri-03.wmv";
m.AllowChangeDisplaySize = true;
m.AutoStart = true;
m.ClickToPlay = true;
m.CurrentPosition = 0;
m.DisplaySize = MPDisplaySizeConstants.mpFullScreen;
m.Enabled = true;
m.EnableFullScreenControls = true;
m.ShowControls = true;
m.ShowDisplay = true;
m.ShowPositionControls = true;
m.VideoBorderWidth = 55;
m.WindowlessVideo = false;
m.PreviewMode = true;
m.ShowAudioControls = true;
m.ShowDialog(MPShowDialogConstants.mpShowDialogContextMenu);
m.ShowDisplay = true;
m.AboutBox();
m.DisplayMode = MPDisplayModeConstants.mpFrames;
m.DisplaySize = MPDisplaySizeConstants.mpDefaultSize;
m.EnablePositionControls = true;
m.ShowCaptioning =true;
MessageBox.Show( m.SourceLink);
m.TransparentAtStart = true;
m.VideoBorder3D = true;
m.SelectionEnd = 66;
m.Play();
but ihad that exeption
Error HRESULT E_FAIL has been returned from a call to a COM component.
iwant know how tosolve this
|
|
|
|
|
Which line is giving the error?
|
|
|
|
|
m.play()
is give the exiption
|
|
|
|
|
Have you set the URL you're trying to play?
|
|
|
|
|
the value which i assinged is only in the first message so
if i didnt write any athintial line tell me
or if u know anther way to run windows mesia player throw c# code or to show vedio throw c# application please tell me
andthank u for ur help
|
|
|
|
|
Can I use a library(dll) created with .net(C#) in a non .net programming language (Borland Delphi for Win32), with .net framework installed?
How do I do that, because I couldn't import the library.
Thanks!
|
|
|
|