|
try the Beginning XML by WROX
Actually I like all WROX books.
www.wrox.com
you should be able to find all of them at amazon..
theJazzyBrain
Wise is he who asks good questions, not he who gives good answers
|
|
|
|
|
I second that!
Excellent book.
Author is David Hunter.
~Mike Stanbrook
|
|
|
|
|
I am creating my first web service using .net. Will clients using perl lite to access my service run into any problems? Is there anything I need to do to make the web service more friendly to non Microsoft users?
Jason W.
|
|
|
|
|
Jason Weibel wrote:
non Microsoft users?
They exist? Ok, just joking. I assume you are talking about this[^]? If so, it looks like it supports both the SOAP 1.1 and 1.2 specs so you should be ok. Have you tried to create a quick example using it, there are plenty of examples listed.
-Nick Parker
|
|
|
|
|
I’m fairly new to the web service world so try not to laugh if this is a dumb question. Using visual studio .net I have created a web service and a client side app to make requests to that service. The current requests are simply passing string variables. If possible I would like to pass the entire contents of an xml document, how is this done?
Thanks
Jason W.
|
|
|
|
|
here is a simple example:
[WebMethod(
Description = "a test of passing XML documents"
)]
public XmlDocument AddElementToDocument(XmlDocument source, string elementName)
{
source.ChildNodes[0].AppendChild(source.createElement(elementName));
return source;
}
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
|
Ok, I have setup the web service as such, basically the VB equivalent of your code:
<br />
<WebMethod()> _<br />
Public Function AddElementToDocument(ByVal source As XmlDocument) As String<br />
Return "Accepted"<br />
End Function<br />
Now I can’t get the client app to pass the document to the service. The function is asking for a system.xml.xmlnode object. Why is it prompting for that and what needs to be done about it? Thanks your help.
Jason W.
|
|
|
|
|
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
|
|
|
|