Anthony Ikeda

Greenhorn
+ Follow
since Jan 23, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anthony Ikeda

Originally posted by Amna Arif:
I am a B.C.S student and now i have to submit my final project. so now help me in deciding that whether ASP is better or JSP is better for me continue my project.


Keep your backend processes separate from your front end and you can use whatever you like.
Anthony
20 years ago
JSP
SOAP (Simple Object Access Protocol) send messages to a remote server with instructions to do something. For example you can have a class existing on one server with certain methods and routines.
Using SOAP (or XML Messaging) you can send an XML structure to make the remote class do something. For example the following XML (WSDL)structure describes the class on the remote server and displays what methods are available to this class:
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" id="urn:ikeda-industries">
<isd :provider type="java" scope="Application" methods="addCompany getAllListings getCompany publishCompanies publishCompany putListings">
<isd:java class="org.ikeda.soap.CompanyListing"/>
</isd :provider>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
<isd:mappings>
<isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:x="urn:ikeda-industries" qname="x:company" javaType="org.ikeda.soap.Company" java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer" xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
</isd:mappings>
</isd:service>
As you can see it defines a class called org.ikeda.soap.CompanyListing. This class allows people to access the methods: addCompany(), getAllListings(), getCompany(), publishCompanies(), publishCompany() and putListings().
You can invoke any of these methods from another class using the following technique:
CompanyListing cl = new CompanyListing();
Company company = new Company("Tone Inc",
"Anthony Ikeda",
"210 Copeland Road(East)",
"Beecroft",
"NSW",
"Australia");
cl.publishCompany("http://localhost:8100/soap/servlet/rpcrouter",company);
Here I'm using the class Company to construct a company (which is what a CompanyListing class is made up of) with cl.publishCompany() I'm sending the details to the soap server (http://localhost:8100/soap/servlet/rpcrouter). These details are now readily available to whoever has similar classes (Company/CompanyListing).
The following example gets the data from the Soap Server:
...
System.out.println(cl.gatherAllCompanies("http://localhost:8100/soap/servlet/rpcrouter"));
It invokes the method on the server (gatherAllCompanies) which gets the data as an element, converts it to a string and returns the string (if you want it can be returned as an element only).
From my experience, SOAP is very "circular" in that the class you use to get the data work on themselves in another location so you are more or less constructing a class to return what it invokes (make sense?). This logic can be separated, but I keep it contained for the sake that I don't have too many classes everywhere.
Anyhow, check out xml.apache.org and look up SOAP for Java if your a Java user, else I'm sure www.google.com will find the right SOAP implementation.
Cheers,
Anthony
[This message has been edited by Anthony Ikeda (edited August 27, 2001).]
The standard escape character for a space is &#160;�or &nbsp;
Cheers,
Anthony
[This message has been edited by Anthony Ikeda (edited August 27, 2001).]
[This message has been edited by Anthony Ikeda (edited August 27, 2001).]
This page translates the escape codes
[This message has been edited by Anthony Ikeda (edited August 27, 2001).]
This depends on what XML package you wish to use (JAXP, Xalan/Xerces, etc) and which language (Java, C++, C#, etc).
For JAXP the easiest way is to use the Xalan transformer to transform the XML to text:
import org.w3c.dom.Node;
import java.io.StringWriter;
import java.utils.Properties
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
...
public static String serializeDoc(Node doc){
StringWriter outText = new StringWriter();
StreamResult sr = new StreamResult(outText);
Properties oprops = new Properties();
oprops.put(OutputKeys.METHOD, "html");
oprops.put("indent-amount", "4");
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = null;
try{
t = tf.newTransformer();
t.setOutputProperties(oprops);
t.transform(new DOMSource(doc),sr);
} catch(Exception e){}
return outText.toString();
}
as you can see, it just uses the Transformer to transform an XML document without a stylesheet, thus you get no transformation except the string. With Xerces, however, you have whats known as Serializers:
import java.io.StringWriter;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.Serializer;
import org.apache.xml.serialize.XMLSerializer;
public static String serializeDoc(Element doc){
String xmlString = new String();
StringWriter stringOut = new StringWriter();
if(doc!=null){
OutputFormat opfrmt = new OutputFormat(doc.getOwnerDocument(), "UTF-8", true);
opfrmt.setIndenting(true);
opfrmt.setPreserveSpace(false);
opfrmt.setLineWidth(500);
XMLSerializer serial = new XMLSerializer(stringOut, opfrmt);
try{
serial.asDOMSerializer();
serial.serialize( doc );
xmlString = stringOut.toString();
} catch(java.io.IOException ioe){
xmlString=null;
}
} else xmlString=null;
return xmlString;
}
as you can see this uses custom classes to "serialize" the document leaving you with a string representation of the xml.
Good luck,
Anthony
I would prefer to use a variable/parameter as it means I can decide at runtime which attribute I want to sort by.
I would prefer to have a different format to the code, unfortunately the software we develop is starting to show a bit of age and does not use XML the way it should.
I can easily use the ./@Surname etc without a hitch.
Anyone able to do this yet?
Cheers,
Anthony Ikeda
How do I perform the same task if my variable is referencing an attribute?
For example:
XML:
<Members>
<Member
EMail="jacky@tech.com"
FirstName="Jacky"
ID="jchau"
Surname="Chau" />
<Member
EMail="will@tech.com"
FirstName="Will"
ID="wbudik"
Surname="Budik" />
<Member
EMail="mel@tech.com"
FirstName="Melany"
ID="mcox"
Surname="Cox" />
</Members>
XSL:
<xsl :param name="ordering">Surname</xsl :param>
<xsl:for-each select="/Config/Member">
<xsl:sort order="ascending" select="$ordering"/>
<tr><td><xsl:value-of select="./@Surname"/></td>
<td><xsl:value-of select="./@FirstName"/></td>
<td><xsl:value-of select="./@EMail"/></td>
</tr>
</xsl:for-each>
It works okay if I use the above technique for a node but the attrbiute won't work unless I put the actual name. (name()==$ordering doesn't work for an attribute)
Cheers,
Anthony Ikeda

[This message has been edited by Ajith Kallambella (edited January 24, 2001).]