|
whats the client code....
also "ByVal" - should be ByRef?
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
|
Hi All,
Can anyone recommend a good book for XML Web Services.
I have been tasked with learning more about this but not sure what book to start with.
Thanks In Advance
Tony
|
|
|
|
|
I have ‘Real World XML Web Services By Yasser Shohoud’ and have gotten a lot out of it. This book is aimed at VB and VB.Net programmer if you don’t fall into that category I would try something else. My one complaint about the book is the examples do not get complex enough. There are some sample chapters and articles by Yasser at http://www.learnxmlws.com/learn/tutors.aspx.
A second book I have is ‘Applied XML Programming for Microsoft .NET by Dino Esposito‘ it is a very good in-depth book about XML programming, it doesn’t touch web services as deeply as Yasser’s book but it has a lot of good stuff in it. All the code in the book is written in C#.
In learning how to program web services I still have had question that I wasn’t able to answer with the books but I think you will have that with ever thing. Both these books are aimed at .net web services so keep that in mind when considering them.
Note, just because I think these are good books doesn’t mean you will agree. I say that because Yasser’s book had several good reviews on amazon and one horrible one. Basically it comes down to were the books worth the $30 I paid for each of them, yes.
Jason W.
|
|
|
|
|
Hi,
I have a method to render HTML from XSLT. Here is the method:
///
/// Method that renders HTML from XSLT document
///
/// <param name="writer" />
protected override void Render(HtmlTextWriter writer)
{
XPathDocument xdoc = new XPathDocument(Context.Server.MapPath(sourceFilePath));
XslTransform xslt = new XslTransform();
xslt.Load(Context.Server.MapPath(transformFilePath));
xslt.Transform(xdoc, null, writer);
}
I am now getting this warning:
warning CS0618: 'System.Xml.Xsl.XslTransform.Transform(System.Xml.XPath.IXPathNavigable, System.Xml.Xsl.XsltArgumentList, System.IO.TextWriter)' is obsolete: 'You should pass XmlResolver to Transform() method'
I need some help resolving this warning. Can you help?
Kyle
|
|
|
|
|
you need to use a XPathNavigator:
XslTransform xslt = new XslTransform();
XmlDocument formDocument = new XmlDocument();
<br/>
sourceDocument.Load(sourceFileName);
formDocument.Load(formFileName);
xslt.Load(stylesheetFileName);
<br/>
MemoryStream ms = new MemoryStream();
<big>XPathNavigator nav = formDocument.CreateNavigator();</big>
<br/>
xslt.Transform(nav, null, ms, null);
<br/>
StreamReader sr = new StreamReader(ms);
ms.Position = 0;
string result = sr.ReadToEnd();
sr.Close();
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Thank you Nick!
I did need to use an XPathNavigator but even then the error message about using XmlResolver still appeared. Upon further research I found that XmlResolver is a argument in the Transform method.
Transform(XPathNavigator, XsltArgumentList, TextWriter, XmlResolver);
I had left this argument out and that is what generated the error. I still have no clue as to when or why to use a XmlResolver but found when I inserted a null for the arguemnt as it appears in your code that the error disappeared.
Transform(nav,null,writer,null);
I suspect you can create custom resolvers to influence the Transform but that's for another day. Problem solved. Thank you.
Kyle
|
|
|
|
|
I am writing an XSL to convert from our old to our new file format, and I want to get back a section showing me the nodes we've not processed. I've written this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:dt="urn:schemas-microsoft-com:datatypes">
<xsl:template match="/XML/results/result/XML">
<XML xmlns:dt="urn:schemas-microsoft-com:datatypes">
<xsl:call-template name="static"/>
<xsl:call-template name="versions"/>
</XML>
</xsl:template>
<xsl:template name="static">
<static>
<id dt:dt="int"><xsl:value-of select="//XML/static/id"/></id>
<file_type dt:dt="int"><xsl:value-of select="//XML/static/filetype"/></file_type>
<date_contributed dt:dt="dateTime"><xsl:value-of select="//XML/static/date_contributed"/></date_contributed>
<remains><xsl:copy-of select="//XML/static"/></remains>
</static>
</xsl:template>
<xsl:template name="versions">
<versions>
</versions>
</xsl:template>
</xsl:stylesheet>
The idea being that right now, all of the static section EXCEPT the id, filetype and date_contributed nodes should be in the remains sections. Any suggestions most welcome.
Christian
|
|
|
|
|
This is probably not what you are looking for, but i mention it anyway.
<xsl:template match="/XML/results/result/XML">
<xml xmlns:dt="urn:schemas-microsoft-com:datatypes">
<xsl:call-template name="static"/>
<xsl:call-template name="versions"/>
</XML>
</xsl:template>
<xsl:template name="static">
<static>
<id dt:dt="int"><xsl:value-of select="//XML/static/id"/></id>
<file_type dt:dt="int"><xsl:value-of select="//XML/static/filetype"/></file_type>
<date_contributed dt:dt="dateTime"><xsl:value-of select="//XML/static/date_contributed"/></date_contributed>
<remains>
<xsl:copy-of select="//XML/static/*[not(name()='id') and not(name()='filetype') and not(name()='date_contributed')]"/>
</remains>
</static>
</xsl:template>
<xsl:template name="versions">
<versions>
</versions>
</xsl:template>
bart
<edit> Whoops, text was gone</edit>
|
|
|
|
|
One possibility might be to use XMLdiff[^] to highlight deltas.
Alternatively, you could investigate modes - you could process the node-set twice, once in a 'processing' mode, once in a 'not-processing' mode, using specific templates only for the nodes you want to process - consider this:
test.xml
<section>
<A>Text A</A>
<A>Text A 2</A>
<B>Text C</B>
<C>Text C</C>
<D>Text D</D>
</section>
test.xslt
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
extension-element-prefixes="redirect">
<xsl:template match="section">
<xsl:element name="test">
<xsl:element name="processed">
<xsl:apply-templates mode="normal"/>
</xsl:element>
<xsl:element name="not-processed">
<xsl:apply-templates mode="show-not-processed"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="A" mode="normal">
<xsl:value-of select="name()"/>
</xsl:template>
<xsl:template match="C" mode="normal">
<xsl:value-of select="name()"/>
</xsl:template>
<xsl:template match="A|C" mode="show-not-processed"/>
<xsl:template match="*" mode="normal"/>
<xsl:template match="*" mode="show-not-processed">
<xsl:value-of select="name()"/>
</xsl:template>
</xsl:stylesheet >
test.out.xml (produced using Xalan 2.3.1 with test.xml as input and test.xslt as the stylesheet)
<?xml version="1.0" encoding="UTF-8"?>
<test><processed>
A
A
C
</processed><not-processed>
B
D
</not-processed></test>
The stylesheet uses the 'match-all' templates to mop up any nodes you don't mention explicitly in a template, so it's just a case of listing all the nodes you process in this template:
<xsl:template match="A|C" mode="show-not-processed"/>
HTH
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Hey CG, sorry for only replying now. Honestly I don't know the answer, I have not done much XSL of late as I am meeting stiff resistance to putting it into practical use. Knowing you though you will have figured it out by now, far better at this than I am.
Paul Watson Bluegrass Cape Town, South Africa
Roger Wright wrote:
Personally, I'm seeking a red-headed, double-breasted mattress thrasher
|
|
|
|
|
Hi Paul. What sort of resistance ? Why would people not want to use it ?
Yes, in the end I wrote rules that specified the nodes I wanted and a rule that specified all other nodes, by listing the ones I wanted and put not in front of it. I was hoping for a sexier solution, but it eluded me.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi all,
I have created an xml dom document dynamically from ADO.save option.. and i hav cleaned the unnecesary schema info from that xml dom object by applying this style sheet...
*******************************************
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema">
<xsl: output indent="yes" method="xml" version="1.0" standalone="yes" />
<xsl:template match="/">
<DATA>
<xsl:apply-templates select="xml/rs:data/z:row"/>
</DATA>
</xsl:template>
<xsl:template match="xml/rs:data/z:row">
<ROW>
<xsl:for-each select="@*">
<xsl:element name="{name()}">
<xsl:value-of select="z:row"/>
</xsl:element>
</xsl:for-each>
</ROW>
</xsl:template>
</xsl:stylesheet>
************************************************
but it is giving output as :
************************************************
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<DATA xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<ROW>
<COUNTRY_CODE></COUNTRY_CODE>
<COUNTRY_NAME></COUNTRY_NAME>
</ROW>
<ROW>
<COUNTRY_CODE></COUNTRY_CODE>
<COUNTRY_NAME></COUNTRY_NAME>
</ROW>
</DATA>
************************************************
But i want the output as :
************************************************
<?xml version="1.0" ?>
<DATA>
<ROW>
<COUNTRY_CODE></COUNTRY_CODE>
<COUNTRY_NAME></COUNTRY_NAME>
</ROW>
<ROW>
<COUNTRY_CODE></COUNTRY_CODE>
<COUNTRY_NAME></COUNTRY_NAME>
</ROW>
</DATA>
************************************************
any modification in stylesheet will help??? ... or can i use removeNamedItem to remove the attributes of the parent .. i.e
For the node :
<DATA xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
Can i use...
Element = objXML.documentElement.parentNode;
Atts = Element.attributes;
RemItem = Atts.removeNamedItem("xmlns:dt")
..ThanX for any help!
Rgds
ksm
ksm
|
|
|
|
|
<xsl:stylesheet exclude-result-prefixes="dt rs z"
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
okay 2 textboxes one box i have user input the other one is a password now i need to bind the userid and the datatime stamp to the listbox that i need to bind to xml file and then call and read that xml file into another listbox on another form
im using c#
Thanks any help would be greatly appreciated.......i checked out the article on msdn and im still lost.
Da Intern
|
|
|
|
|
is there any way to make a selection of the top 5 (or any number) rows with certain attributes.
I'm used to SQL language and have tried some of the xml features for this too but haven´t seen anything about selecting a certain number of "rows".
Anyone who knows?
Regards
M
|
|
|
|
|
You can use XPath to contruct a query, then depending on what language you are using to implement this you could (C# exmample):
public XmlNodeList Search(string input)
{
string query = "/mainnode/subnode/[name = " + input.Trim().ToString() + "]";
XmlDocument doc = new XmlDocument();
doc.Load("mydata.xml");
XmlNodeList nodes = doc.SelectNodes(query);
return nodes;
}
Then just iterate through your return XmlNodeList 5 times. I suppose there are other ways to do this, this is just a quick example.
-Nick Parker
|
|
|
|
|
Yep, the "pure" xsl solution will be using position() I believe, like this:
"/store/books[position() <= 5]"
This will select 5 first books
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Hi
I'm trying to access a sequence which is part of a node in an XML file.
<br />
<property pr_ref="ABC" ... ><br />
<sellingpoint text="HALLWAY" /><br />
<sellingpoint text="DINING ROOM" /><br />
<sellingpoint text="KITCHEN" /><br />
</property><br />
I can iterate through the "property" nodes and retrieve their columns (pr_ref) but how on earth do I access the sequence of selling points? I've tried childrows and parents rows and I'm lost!
I'm using VB.NET and I have the entire file in a DataSet. The second table of the dataset seems to contain ALL of the sellingpoint rows, not just those related to the one property.
I'm desperate!
Bernhard
Don't worry, nobody lives forever.
|
|
|
|
|
Well, if you have created the class for handling your dataset (Generate code or something), then you should be able to use a function of propertyRow , which named like GetSellingpointRows() .
If you don't see it, then you can try using GetChildRows anyway. I can't help you much with VB, but here is a link to IBuySpy[^]. You can download a VB version and see how they did this (look in PortalCfg.vb and Components/Configuration.vb):
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Not sure this is the right forum but I have a problem generating XML for my IE Treeview Web control. With XML Explicit I get a long XML string that truncates returned data before generating the next line of code. I can only assume it's exceeded the 255 char record limit for SQL Server 2000 and is truncating data. The example in CODE PROJECT doesn't seem to address this because their sample of data is small. Any ideas? Thanks.
|
|
|
|
|
|
I have a rule that looks like this:
<xsl:template match="item" >
<item>
<xsl:apply-templates />
</item>
</xsl:template>
This matches all <item> nodes in my source document. However, the source document contains <item xsi:type="ns:AAA"> and <item xsi:type="ns:BBB"> nodes.
I want only the AAA nodes to be picked up. Any ideas...?
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Have you tried item[@xsi:type='ns:AAA'] as the match attribute?
|
|
|
|
|
Worked like a charm!
Thanks
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|