• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Fresher ! need help

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
Iam preparing for IBM-XML cert.
I like to work out some examples. May be it's a silly question :-(
could u pls reply me what r all the parsers & tools i need,to run a XML program in a PC.
I need a java based Parser!Plz help me with the links.
thanks for ur time
 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
The following info is a little exhaustive. Please go through it completely,
I tried to compile a list of resources for preparing for the IBM XML test141. Please come back with any comments/suggestions/clarifications.
DISCLAIMER � I�ve not yet taken the test and the following list is what I�m following
EXAM INFO - http://www1.ibm.com/certify/certs/adxm_apd.shtml
Exam pattern � IBM has changed the pass percentage from 65% to 58% and the no. of questions were lowered from 59 to 55. Hence we need to get a minimum of 32 correct answers in order to clear the exam. All of them are going to be multiple choice types. Seems that they also mention the number of correct answers for the non-radiobutton questions.
Mock Exams � The best mock exam I could find out till date is that of the IBM website�s given here ----- http://certify.torolab.ibm.com/icetest.jsp You just need to create some login and everything is free.
AND
JavaRanch mock exams under the xml certification forum.
Books (hardcopies) - Professional XML2. No other hard copies are required in my opinion. Exhaustive list of reading material available on the web follows J
SoftCopies
===========
�Lots of sample chapters available topic-wise at http://www.perfectxml.com/FreeLibrary.asp
�The following are links for preparing for XML-Databases part of the exam �
http://www-106.ibm.com/developerworks/library/x-struct/?dwzone=xml
http://www.rpbourret.com/xml/SchemaMap.htm
http://www.extensibility.com/tibco/resources/modeling.htm
http://www.rpbourret.com/xml/XMLAndDatabases.htm
http://www.xml.com/pub/a/2001/05/09/dtdtodbs.html?page=1

MAIN TOPICS WE NEED TO CONCENTRATE UPON
Remember �.. You need to verify the concepts with the help of tools (provided here) in order to understand them thoroughly.
1.General XML and DTDs � XML Bible has very good introduction to these concepts including in-depth coverage of entities and all that good stuff of DTDs.
Testing tool
http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/Downloads/samples/Internet/xml/xml_validator/Default.asp
The above link has microsoft�s xml validator. I use this for validation of my xml instance documents against the DTDs. I think this can also be used to validate against schemas, but I never tried it.
2.Schemas � You need to get Roger Costello�s tutorial from the following location. It is simply the best available on the web. It has 3 ppt files on schemas.
http://www.xfront.com/xml-schema.html
Testing tool
The xml schema validator XSV given here is provided on Roger Costello�s website given here � ftp://ftp.cogsci.ed.ac.uk/pub/XSV/XSV12.EXE
This can be used to validate the xml documents against the schemas we write.
3.XSLT � One of the best tutorials available on the web for xslt is given below. The best part is that it explains things with examples.
http://zvon.org/xxl/XSLTutorial/Output/contents.html
Testing tool
You need to have Xalan�s Java based XSLT processor and the following details you how to install that stuff on your m/cs (you need to have Java SDK1.2 or later).
This takes care of 3 birds in one shot XSLT, DOM and SAX testing tools �
http://xml.apache.org/xalan-j/
You will be applying the stylesheets to the xml files from the command line.
The following are the sequence of steps i followed to get the stuff working on my m/c -
1) download xalan-j_2_4_0-bin.zip from the above site
2) extract the zip file in any of the directories
3) You then need to go to the xalan/bin directory and extract the contents of some of the jar files here as "jar -xvf xalan.jar", then the same thing for xercesImpl.jar and xml-apis.jar. This process will basically extract all the class files which will be used by the our xslt processor.
4) The most important thing then is to update the CLASSPATH variable on our m/c with the absolute path of our xalan/bin directory.
5) To ensure that everything is properly set up on ur m/c, you need to run the following command from the command line -
java org.apache.xalan.xslt.Process
and it should give you a list of options as shown below -
=================================================
-IN inputXMLURL
-XSL XSLTransformationURL
-OUT outputFileName
-V (Version info)
-QC (Quiet Pattern Conflicts Warnings)
-TT (Trace the templates as they are being called)
-TG (Trace each result tree generation event)
-TS (Trace each selection event)
-TTC (Trace the template children as they are being processed)
-EDUMP [optional]FileName (Do stackdump on error)
-XML (Use XML formatter and add XML header)
-TEXT (Use simple Text formatter)
-HTML (Use HTML formatter)
-PARAM name value (Set a stylesheet parameter)
-DIAG (Print number of milliseconds transform operation took)
-FLAVOR flavorName (Transform with SAX for s2s or DOM for d2d)
-URIRESOLVER fullClassName (Use a custom URIResolver)
-ENTITYRESOLVER fullClassName (Use a custom EntityResolver)
-CONTENTHANDLER fullClassName (Use a custom ContentHandler)
-INCREMENTAL (Request incremental transform by setting
http://xml.apache.org/xalan/features/incremental to true)
-NOOPTIMIZE (Request no optizimation of stylesheet processing
by setting http://xml.apache.org/xalan/features/optimize to
false)
-RL recursionLimit (Set numeric limit on depht of stylesheet
recursion)
-L (Turn on source_location attribute)
================================================
This make sure that you are all set to go. If you didnot set the classpath stuff properly, you will get the no class defintion found error. Also one common mistake people do is forget to include the current directory �.� In their classpath.
6) Next thing is that you need to write a sample test.xml file (say) and write some xsl file for that (test.xsl) and run the command as follows -
java org.apache.xalan.xslt.Process -in test.xml -xsl test.xsl -out test.txt
You can find all these details at http://xml.apache.org/xalan-j/
Xpath and XSLT are inter-twined. We have a good tutorial for Xpath at the following location - http://www.oreilly.com/catalog/xmlnut/chapter/ch09.html
4.DOM - Java�s Xalan Xslt processor has all the DOM API implementation classes for java. Read the above procedure for installing the xalan processor carefully and this will set up the required things for DOM and SAX in java.
The best way for understanding the DOM API in my opinion is try to practice one of its implementations. I�m following Java�s from the following website �
http://java.sun.com/j2se/1.4.1/docs/guide/plugin/dom/org/w3c/dom/package-summary.html
I�m giving you a small java program written using this DOM API to give you a head start to start working with this. Please go through the code thoroughly to understand the process. In a nutshell, I�m trying to walk through the DOM tree build by parsing the xml file �aa.xml�. You need to copy the following xml code in a file named aa.xml and the java code in a file named order.java.
XML File to be parsed �
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE orders [
<!ELEMENT orders (order*)>
<!ELEMENT order (customerid, status, item*)>
<!ELEMENT item ANY>
<!ELEMENT status (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT qty (#PCDATA)>
<!ATTLIST customerid limit CDATA #REQUIRED>
<!ATTLIST orders Notation ENTITY #IMPLIED>
<!ATTLIST item instock CDATA #REQUIRED
itemid CDATA #REQUIRED>
<!ENTITY jaya "WB78">
<!ENTITY jayaTwo "&elementEntity;">
<!ELEMENT jaya (#PCDATA)>
<!ENTITY elementEntity "<jaya>jayadev</jaya>">
<!NOTATION jaya SYSTEM "jaya.exe">
<!ENTITY giffile SYSTEM "demo.gif" NDATA jaya>
]>
<?PI-1 this is first processing instruction?>
<orders Notation="giffile">
<order>
<?PI-2 this is second processing instruction?>
<customerid limit="1000">12341</customerid>
<status>pending</status>
<item instock="Y" itemid="SA15">
<![CDATA[hi there]]>
<name>Silver Show Saddle, 16 inch</name>
<price>825.00</price>
<qty>1</qty>
</item>
<item instock="N" itemid="C49">
<![CDATA[hi there]]>
<name>Premium Cinch</name>
<price>49.00</price>
<qty>1</qty>
</item>
</order>
<order>
<?PI-3 this is third processing instruction?>
<customerid limit="150">251222</customerid>
<status>pending</status>
<item instock="Y" itemid="&jaya;">
&jayaTwo;
<!-- &giffile; -->
<![CDATA[hi there]]>
<name>Winter Blanket (78 inch) &jaya;</name>
<price>20</price>
<qty> 10</qty>
</item>
</order>
</orders>
DOM Java CODE �
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import java.io.File;
import org.w3c.dom.*;
public class order{
public static int depth;
public static void changeOrder(Node root, String elementName,
String elementValue)
{
Node n;
Node firstChild;
try{
Document doc = root.getOwnerDocument();
NodeList nList = doc.getElementsByTagName(elementName);
for(int i=0; i<nList.getLength(); i++)
{
n = nList.item(i);
// text node will be the first child
firstChild = n.getFirstChild();
firstChild.setNodeValue(elementValue);
}
}
catch(DOMException de)
{
System.out.println("DOMException::"+de.toString());
}
catch(Exception e)
{
System.out.println("Exception::"+e.toString());
}
}
public static void showAttributes(Node element)
{
NamedNodeMap nnMap = element.getAttributes();
Node indexedNode;
for(int i=0; i<nnMap.getLength(); i++)
{
for(int j=0; j<depth; j++) System.out.print(" ");
indexedNode = nnMap.item(i);
System.out.println("ATTR::"+indexedNode.getNodeName()+"="+
indexedNode.getNodeValue()+"("+getNodeType(indexedNode)+")");
}
}
public static String getNodeType(Node node)
{
short type;
type = node.getNodeType();
String retNode = "UNKNOWN";
if(type == node.ELEMENT_NODE) retNode="ELEMENT_NODE";
if(type == node.ATTRIBUTE_NODE) retNode="ATTRIBUTE_NODE";
if(type == node.COMMENT_NODE) retNode="COMMENT_NODE";
if(type == node.PROCESSING_INSTRUCTION_NODE) retNode="PROCESSING_INSTRUCTION_NODE";
if(type == node.ENTITY_REFERENCE_NODE) retNode="ENTITY_REFERENCE_NODE";
if(type == node.ENTITY_NODE) retNode="ENTITY_NODE";
if(type == node.NOTATION_NODE) retNode="NOTATION_NODE";

if(type == node.TEXT_NODE) retNode="TEXT_NODE";
if(type == node.DOCUMENT_NODE) retNode="DOCUMENT_NODE";
if(type == node.DOCUMENT_TYPE_NODE) retNode="DOCUMENT_TYPE_NODE";

if(type == node.CDATA_SECTION_NODE) retNode="CDATA_SECTION_NODE";
if(type == node.DOCUMENT_FRAGMENT_NODE) retNode="DOCUMENT_FRAGMENT_NODE";
return retNode;
}
public static void recurseNodes(Node node)
{

for(int i=0;i<depth; i++) System.out.print(" ");
// print the node information
if(node.getNodeType() == node.TEXT_NODE)
{
if(node.getNodeValue().trim().length() > 0){
System.out.println(node.getNodeName()+"="+
node.getNodeValue()+"("+getNodeType(node)+")");
}
else
{
System.out.println(node.getNodeName()+"="+"("+getNodeType(node)+")");
}
}
else
{
System.out.println(node.getNodeName()+"="+
node.getNodeValue()+"("+getNodeType(node)+")");
}
// print the node attributes
if(node.getNodeType() == node.ELEMENT_NODE)
showAttributes(node);
// recurse thru the children
Node firstChild = node.getFirstChild();
while(firstChild!=null)
{
depth ++;
recurseNodes(firstChild);
firstChild = firstChild.getNextSibling();
}
depth--;
}
public static void main (String args[]) {
File docFile = new File("cc.xml");
Document doc = null;
NamedNodeMap nnMap = null;
int i;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
dbf.setExpandEntityReferences(false);
dbf.setIgnoringElementContentWhitespace(true);
DocumentBuilder docb = dbf.newDocumentBuilder();
doc = docb.parse(docFile);
Element root = doc.getDocumentElement();
System.out.println("RootElement::"+root.getNodeName());
NodeList nList = root.getChildNodes();
System.out.println("No. of children for root node "+
nList.getLength());
depth=0;
/*
//recurseNodes(root);
// Details of the DTD
System.out.println("-------------DTD DETAILS----------");
DocumentType docType = doc.getDoctype();
System.out.println("DTD Name ::"+docType.getName());
nnMap = docType.getEntities();
System.out.println("No. of general Entities ::"+nnMap.getLength());
// Entity information
for(i=0;i<nnMap.getLength();i++)
{
System.out.println("Index ::"+i+""+nnMap.item(i).getNodeName()+"="+
nnMap.item(i).getNodeValue());
}
nnMap = docType.getNotations();
System.out.println("No. of Notations ::"+nnMap.getLength());
// Entity information
for(i=0;i<nnMap.getLength();i++)
{
System.out.println("Index ::"+i+""+nnMap.item(i).getNodeName()+"="+
nnMap.item(i).getNodeValue());
System.out.println("Notation SYSTEM ::"+((Notation)nnMap.item(i)).getSystemId());
}
// changing the element content
// changeOrder(root, "status", "processed");
// recurseNodes(root);
// adding new nodes
Element newElement = doc.createElement("newElement");
// TBD:: Try to set a node value to an element node
// TBD:: Try to create an element with an invalid name
Node textNode = doc.createTextNode("newTextNode");
textNode.setNodeValue("NEW TEXT");
newElement.appendChild(textNode);
root.appendChild(newElement);
root.insertBefore(newElement, root.getFirstChild());
root.removeAttribute("Notation");
//root.normalize();
//recurseNodes(root);
System.out.println(root.toString());
*/
/*
Node n = doc.getElementsByTagName("order").item(1);
NodeList l = ((Element)n).getElementsByTagName("qty");
Node nn = l.item(0);
Text t = doc.createTextNode("Move along, nothing to see here.");
nn.appendChild(t) ;
*/
recurseNodes(root);
/*
root.normalize();
recurseNodes(n);
*/
}
catch (DOMException de)
{
System.out.println("DOM Exception ::"+de.toString());
}
catch (Exception e)
{
System.out.println("EXCEPTION::"+e.toString());
System.out.println(e.getClass());
}
}
}
5.SAX - SAX preparation should be very similar to DOM. The following website gives you Java�s implemtation of the API. All the java classes required to run examples are already available as a part of installing the xalan�s xslt processor on your m/c.
http://java.sun.com/j2se/1.4.1/docs/api/org/xml/sax/package-summary.html

Try to be in take as many DIFFERENT mock exams as possible. All the best for your exam and please wish me good luck.
Regards,
Jayadev.
 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
patrickm,
Please review the JavaRanch Naming Guidelines and change your login name.
Thanks,
 
patrick gee
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jaydev,
Ur reply is a wonderful resource.
I will try to do that if i have any problem i will get back to u.
thanks man.
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jayadev,
Can you please tell how to use the schema validator XSV to validate the xml documents against the given schemas
Thanks
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anitha Lingam:
Jayadev,
Can you please tell how to use the schema validator XSV to validate the xml documents against the given schemas
Thanks


Hope you won't mind if i reply.
One easy way is go to the directroy where the xsv.exe is located(usually at /xsv12/ directory)
Now store ur xml and/or xsd file in this directory (say foo.xml )
then open the command prompt at this location.
typexsv -o result.xml -s xsv.xsl foo.xml
Now open result.xml in IE or mozilla u will see the result of the validation.
The another way is to use it online at http://www.w3.org/2001/03/webdata/xsv
Regards
Balaji
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Balaji,
Thanks for the reply. I learnt something from it. I generally use it as "xsv test.xml" and try to see the result on the screen. With the stuff u gave, we can see it in an output file and that is really convenient.
Regards,
Jayadev.
 
patrick gee
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,
I try to validate the bookstore.xsd file thr' online it says "NO error".
But when i try to do that thr' command prompt
It says parser error... crash = "true" &
bug = "validator crashed during target reading".
Why is that?
I try to do store the output in result.xml file like balaji told, there is nothing get stored even error msg.
Help me with this!
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best thing in think is to do it locally thru the command prompt. If you can give the code for xml and the schema file in your reply, i'll try to figure out what's wrong with that.
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by patrickgee:
Hi folks,
I try to validate the bookstore.xsd file thr' online it says "NO error".
e with this!


Here u r trying to validate the XSD so u need to change the command option with -i
for example to validate a schema foo.xsd
use
xsv -o result_schema.xml -s xsv.xsl -i foo.xsd
BYW patrickgee plz read the message from John Wetherbie
 
patrick gee
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks balaji,
It WORKS!
Reg. John lot of naming policies in ranch!everything is already reserved.
i cant find any useless display name, which i can remember other than my name! Sorry now i changed that.
 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the xml resources.
 
Anitha Lingam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Balaji and Jayadev, Thanks to both of you.
 
patrick gee
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
Can u guys tell me any other good resources for DOM & SAX.
For XML certification do i have to concentrate more for SOAP & WSDL?
What kind of questions can i expect from these 2?
Thanks for ur time.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
xmlbeginner,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name (change it here) to comply with our unique rule. Thank you.
PS: Quote from the naming policy:


For your publicly displayed name, use a first name, a space, and a last name. Obviously fictitious names or improperly formatted names may be locked out.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic