Creating schema from an XML file in Java

I know that there are a lot of tools out that that do this, but I need some special conversion done.
Is there any source code out there that shows you how to take in an XML file and generate schema for it using Java? The only thing I found used C# and various Microsoft XML classes that don't either exist or do different things in Java.
Thanks!

Refer "trang" in http://hacks.oreilly.com/pub/h/2106. The jar will have to be present in Classpath as well.
But it is always better to first define schema rather than generating constraints(schema) based on a XML instance. A generated schema may not have all the constraints that your application might need for enforcement.

Similar Messages

  • Load Multiple Tables (schemas) from same XML file

    Hi,
    This is first time i am working XML files.
    I have one XML file with two tables (schema). I need to load those two tables into two different Target tables.
    This is the startegy to choose tables.
    <Entry type="full"> --Table 1
    <Entry type="short">--Table 2
    I am try to find the tables like this using condition split (Type == "Full" ) but tables are not splitting as expected, is am i going with wrong approach??
    Can anyone suggest me to process multiples tables from same XML file??

    Hi Naveen,
    After the issue in my environment, the package works well that the data in the XML file load to two destination tables based on one column values. The screenshot is for your reference:
    To troubleshoot this issue, could you please check the values in the type column? Verify the values have exactly the same characters, case sensitivity. It seems that you haven’t write correct values in the Conditional Split Transformation. They should be like
    below:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
     If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • Specifying Schema Location in XML file and not in the Java code

    I have a repository of schema xsd files. When I receive my xml file, I need to validate it against the specified schema. The xml file would declare the schema location, using the following syntax:
    <CERD:CERD xsi:schemaLocation = "..\CERD.xsd" xmlns:CERD = "CERD.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
    Is it really necessary to define the schema location again in the JAVA code? Why set the schemaLocation in the xml file at all then?
    Does anybody have any examples where the schema location is not set in the JAVA code? I am using Java 1.6, and at this point in time I only need to validate. Any help would be appreciated.

    Thank you very much for your quick reply. I have made some progress but I am still stumped.
    In my code I am doing this:
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = factory.newSchema();
    Validator validator = schema.newValidator();
    validator.validate(XML_SOURCE);
    I find this works if my schema does not have a target namespace. I have downloaded the following simple example from the internet that uses a target namespace and it fails:
    library1.xsd:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://example.org/prod"
    xmlns:prod="http://example.org/prod">
    <xsd:element name="product" type="prod:ProductType"/>
    <xsd:complexType name="ProductType">
    <xsd:sequence>
    <xsd:element name="number" type="xsd:integer"/>
    <xsd:element name="size" type="prod:SizeType"/>
    </xsd:sequence>
    <xsd:attribute name="effDate" type="xsd:date"/>
    </xsd:complexType>
    <xsd:simpleType name="SizeType">
    <xsd:restriction base="xsd:integer">
    <xsd:minInclusive value="2"/>
    <xsd:maxInclusive value="18"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:schema>
    <prod:product xmlns:prod="http://example.org/prod"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="library1.xsd"
    effDate="2001-04-02">
    <number>557</number>
    <size>10</size>
    </prod:product>
    I get the following SAXParseException when I validate:
    [line 4, col 36|
    cvc-elt.1: Cannot find the declaration of element 'prod:product'.
    Am I doing something wrong with the namespace declaration?
    Edited by: alfredamorrissey on Oct 31, 2007 6:34 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to get the values from xml file to java combo box

    Hi frens,
    I am new to java and xml programming,
    Now, i want to have a code of getting the tag values from the xml file
    into the swing combo box of java front end.
    How can we do that?
    any help of code or tutorial or an ebook is a great help for me.
    Thank you,
    Karthik.
    Edited by: Karthik84 on Aug 27, 2008 1:49 AM
    Edited by: Karthik84 on Aug 27, 2008 11:29 PM

    look at this link
    http://www.stylusstudio.com/docs/v2006/d_help30.html
    I read sometime back that castor has a tool to do
    conversion. You might have a look into casto as well.

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • Create a list from an XML file    no display

    I have a multiline Dynamic text box called projList.
    I am trying to populate it from an xml file and create a
    clickable list.
    The trace works but cannot get to display the list in the
    text box.
    As far as the clickable goes, haven't gotten that far yet.
    Help very much appreciated.
    The xml is structured like this:
    <?xml version="1.0" ?>
    - <images>
    - <pic>
    <Image>/Butler/Images/sfah2_small.jpg</Image>
    <Category>Institutional</Category>
    <Proj_title>FRESH AIR HOME</Proj_title>
    Please see code below:
    import mx.xpath.XPathAPI;
    var allproj_xml:XML = new XML();
    allproj_xml.ignoreWhite = true;
    allproj_xml.onLoad = function(success:Boolean) {
    trace("onload...");
    if (success) {
    trace("success...");
    var thePath_str:String = "/images/pic/Proj_title";
    var title_array:Array =
    XPathAPI.selectNodeList(this.firstChild,
    thePath_str);
    for (var i:Number = 0; i < title_array.length; i++) {
    trace(title_array
    .firstChild.nodeValue);
    projList.addItem(title_array.attributes.Proj_title);
    } else {
    trace("error loading XML");
    allproj_xml.load("allimages.xml");
    stop();

    This did it:
    projList.addItem(title_array
    .firstChild.nodeValue);
    > Thanks for your response.
    > How can I add what I am tracing, to the component
    properly?
    >
    > "DMennenoh **AdobeCommunityExpert**"
    <[email protected]> wrote in
    > message news:eqaejh$bi8$[email protected]..
    >>>>trace(title_array.firstChild.nodeValue);
    >> projList.addItem(title_array
    .attributes.Proj_title);
    >>
    >>
    >> Your code seems OK. What you are tracing here
    however isn't what you're
    >> adding to the component. Are you sure what you're
    adding traces?
    >>
    >> --
    >> Dave -
    >> Head Developer
    >> www.blurredistinction.com
    >> Adobe Community Expert
    >>
    http://www.adobe.com/communities/experts/
    >>
    >

  • Is there any way to generate pdf from an xml file using single java class

    i m working on generating a pdf file from an xml file. i want to use only a single java class to do so. if theres any such code available please help me to find out.
    Thanks
    Gurpreet Singh

    exactly,
    here are some libraries which are open sources;
    http://java-source.net/open-source/pdf-libraries hope it's useful. :D

  • Passing Parameters from XML file to Java Application

    Can any one help me to know the way of passing values from XML file to Java Application..
    Thanx in advance

    With the Processing Instructions <?name pidata?>
    Get the Nodes in a Document.
    Node node;
    if(node.getNodeType()==Node.PROCESSING_INSTRUCTION_NODE)
    //String param=node.getData();

  • How to create and modify an XML file from an Oracle Form

    I would like to build an Oracle Form to maintain a small XML file in the file system (i.e. Not in Oracle database but in the operating system).
    I would like the Form to display existing values from the XML file and the user can update and save content back to the XML file.
    Can any one tell me how this can be done? Thanks.

    Does Forms 9i provide any XML Parser Functions?
    Can I insert the XML file into a table column by inserting XML using the XSU Front End rather than using TEXT_IO to maintain the XML file directly?
    Can I use XSU PL/SQL API in Forms to retrieve and modify XML values?
    Any help is appreciated.

  • How can I read an XML string that's not from an XML file?

    I've got a script I'm trying to setup that communicates over a socket to retrieve different directions from a custom built Java program.  The Java program listens to requests from the Adobe scripting engine (in my case it's a Photoshop script) on a socket and immediately responds with the next set of directions.  These directions are currently in XML format.  The issue I'm having is that I can't parse the XML data since it's entered into a new XML object from a string rather than being read from a file.  Even without the socket code, you can see the issue by doing the following:
    var xml = new XML("<test><data>hey!</data></test>");
    alert(xml.test.data);
    alert(xml);
    The first alert "should" return "hey!" (without quotes, of course), but it doesn't, while the second alert returns what you would expect it to:
    <test>
        <data>hey!</data>
    </test>
    It works fine if read from an XML file, but from a string, like shown above, it just presents an empty alert box when attempting to access "xml.test.data".  Any ideas on how to fix this issue?  Can it be fixed?  Has it been fixed in newer versions (I'm currently using CS4)?
    Thanks in advance for any help!

    Duh... found my error... I was attempting to access the data by referencing the created "root" element.  Since <test> is the very first element tag, it's setup as the root element, which you don't need to reference.  Changing the alert to alert(xml.data); fixed it.
    Now I just feel dumb, lol...

  • Creating jsf faces-config.xml file

    Hello.
    I'm a newbee on Sun Java Studio Enterprice and have just converted from Borland Jbuilder.
    In borland, if I create a new "webmodule" and include the jfs library, Borland automaticaly creates the faces-config.xml file for me. The IDE then helps me keep this file up to date.
    After creating a new project in Sun Java Studio Enterprice I have gone into propereties and included the jsf-1_1_01.zip file (I googled jsf library and found this file. If I include this file I get access to the <h: -taglib etc so it seems to be working). But the IDE doesn't create the faces-config.xml file.
    Do I need to create this manually or what do I do wrong?

    As an alternative to Creator (which mostly implies WYSIWYG editing of JSP pages) you can consider NetBeans 5.0 or NetBeans 5.5 Beta. They also support JSF.

  • How to save an n-ary tree of nodes to and from an xml file

    Hello,
    I am trying to represent a n-ary tree of nodes in xml.
    More accurately, I am trying to save/instantiate a
    tree of nodes to-from an xml file.
    How do I represent the parent-child relationships?
    Java: (simplified)
    class Node {
    Arraylist childNodes;
    Node parent;
    XML:
    From what I have been learning about XML,
    DTD:
    <?xml version="1.0" ?>
    <!DOCTYPE acd
         <!ELEMENT Node (childNodes, parent)>
         <!ATTLIST Node id ID #REQUIRED>
         <!ELEMENT childNodes (Node*)>
         <!ELEMENT parent (Node?)>
    ]>
    Qs:
    1) How do I represent the relationships? What would
    normally be a reference in Java, how do I represent in
    XML?
    2) Do I use ID, IDREF? I have been trying to find some
    examples to learn how. i.e. Does the IDREF, ID
    automatically become an in-memory reference (or pointer)?
    3) Is it preferable to use XML schema?
    thanks,
    Anil Philip
    Olathe, KS
    for good news go to
    http://members.tripod.com/goodnewsforyou/goodnews.html

    I downloaded XML Spy and used it to correct my earlier schema.
    Qs:
    In the instance document xml file;
    1) How would one display the parent node?
    2) If a child has a reference to a parent node as in the schema below, how can one know that the references are the same?
    i.e. when the parent node is first declared and when it is referred to by the child.
    Perhaps this raises a larger question - how does XML handle recursive references?
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://juwo.com/acd" xmlns="http://juwo.com/acd" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:annotation>
              <xs:documentation>ACD nodes. juwo LLC 2005</xs:documentation>
         </xs:annotation>
         <xs:complexType name="Node">
              <xs:sequence>
                   <xs:element name="parent" type="Node" minOccurs="0"/>
                   <!-- Node[] childNodes -->
                   <xs:element name="childNodes" type="ListOfNodes"/>
                   <!-- String data -->
                   <xs:element name="data" type="xs:string"/>
              </xs:sequence>
              <!-- Node parent -->
         </xs:complexType>
         <xs:complexType name="ListOfNodes">
              <xs:sequence>
                   <xs:element name="i" type="Node" minOccurs="0" maxOccurs="unbounded"/>
              </xs:sequence>
         </xs:complexType>
    </xs:schema>

  • The nicest way to generate xml-files by Java???

    I have to generate huge and quite complex xml files by Java. I have to fetch the data from a Oracle database. What I really don't know is a proper and reliable way to this? I could of course create a String and concatenate all the tags, attributes and data but it doesn't feel right. I guess this is a quite common task and there are many established ways to this by Java. My question is what is the best way to this? What is your suggestion?
    Thank you for any clues...

    Hi,
    Since you have access to the database, I think one of the best way is to create stored procedures that will generate those files for you (using SQL/XML functions preferably) and return the content to the Java caller.

  • How to generate GUI code from parsed XML file?

    hai,
    I have to generate GUI code after parsing any configuration XML file as input.Now i have parsed my XML file and got its attributed and i want to get some idea of how to map the parsed XML attributes to the java code to build GUI code.

    Hello,
    1. I like to create data type from a XML file structure, which contains the data structure ?
    XML fields will need to be taken note of to see which is repeating or not. You can also load the XML into a third-party tool such as Altova XML Spy and then generate an XSD from there. You will need to import the XSDs into PI under external definitions. However, this does not guarantee business interoperability, as such, it is always best to ask the provider for the XSDs or WSDL. It will also save you a lot of time from guessing which fields are needed or not.
    2. How to create custom node function in graphical mapping editor ?
    In your graphical mapping editor, on the lowest left corner, there is an icon there that says Create New Function. You must take into account their return types:
    1. Single Values = String
    2. Queue/Context (no return type) thus resultList is used.
    Hope this helps,
    Mark

  • Create the missing server.xml files yourself

    Paula and I created the missing server.xml files ourselves. The script is at the bottom of the post.
    We badly needed the missing server.xml files to work on the customizations and Oracle was unable to solve this problem.
    "I checked on our Automated Release Updates System found that we dont have server.xml that includes PosDelivSchedVO. This confirms that there is no patch available at present to provide you with this file.
    As this is not related to coding issue,Support will not be able to log a bug with Development. You may log an Enhancement Request via Metalink, so that Development would review your requirement and if feasible would include this file at the time of future releases"
    #!/bin/sh
    # This script is used to generate the missing server.xml files for $JAVA_TOP/oracle/apps/pos
    # Usage: server.sh
    # Note: This script has many hardcoded codes and it may generate the wrong server.xml.
    # The manual fixes to the generated server.xml may be need.
    # Check the codes before you use it.
    # It's possible to write a generic version of this script to deal with more issues, like
    # 1. dealing with the Oracle apps patches applied
    # 2. only generates the missing server.xml files automatically
    # 3. can specify the module, like pos or po ..., to generate server.xml.
    # 4. including only the OA Framework objects used.
    # 5. correctly generate the right "encoding"
    # Luke Chi
    APP=pos
    PKG_HEAD=oracle.apps.$APP
    PKG_TAIL=server
    SERVER_FILENAME=server_1.xml
    cd $JAVA_TOP/oracle/apps/$APP
    # for SUB_DIR in asn isp lov product rcv sbd ship administration changeorder jar planning profile registration schema servic
    es suppreg
    for SUB_DIR in asn lov product rcv ship administration planning profile schema services suppreg
    do
    echo $SUB_DIR
    cd $SUB_DIR/server
    PKG=$PKG_HEAD.$SUB_DIR.$PKG_TAIL
    cat << EOF > $SERVER_FILENAME
    <?xml version="1.0" encoding='WINDOWS-1252'?>
    <!DOCTYPE JboPackage SYSTEM "jbo_03_01.dtd">
    <!-- \$Header: server.xml 115.11 2003/03/25 22:31:14 luke ship $ -->
    <JboPackage
    Name="server"
    SeparateXMLFiles="true"
    EOF
    echo " PackageName=\"$PKG\" >" >> $SERVER_FILENAME
    ls *.xml | grep -v server*.xml | while read FILE
    do
    BASENAME=`basename $FILE .xml`
    cat << EOF >> $SERVER_FILENAME
    <Containee
    Name="$BASENAME"
    FullName="$PKG.$BASENAME"
    EOF
    for TYPE in AM EO VL VO AO
    do
    BASENAME_2=`basename $BASENAME $TYPE`
    if [ $BASENAME_2 != $BASENAME ]; then
    case $TYPE in
    AM) echo " ObjectType=\"AppModule\" >" >> $SERVER_FILENAME ;;
    EO) echo " ObjectType=\"Entity\" >" >> $SERVER_FILENAME ;;
    VL) echo " ObjectType=\"ViewLink\" >" >> $SERVER_FILENAME ;;
    VO) echo " ObjectType=\"ViewObject\" >" >> $SERVER_FILENAME ;;
    AO) echo " ObjectType=\"Association\" >" >> $SERVER_FILENAME ;;
    CO) echo " ObjectType=\"Luke_CO\" >" >> $SERVER_FILENAME ;;
    *) echo " ObjectType=\"Luke_UNKNOWN\" >" >> $SERVER_FILENAME ;;
    esac
    break
    fi
    done
    echo " </Containee>" >> $SERVER_FILENAME
    done
    echo "</JboPackage>" >> $SERVER_FILENAME
    grep Luke $SERVER_FILENAME
    if [ $? -eq 0 ]; then
    mv $SERVER_FILENAME server_error.xml
    fi
    pwd
    cd ../..
    done

    We loaded the Oracle seeded BC4J components from mid-tier file system to jdev OA Framework using the server.xml files generated by our Unix script attached in the privious posting above. We ,then did the customizations and successfully deployed them to our test Oracle apps.

Maybe you are looking for

  • I'd like to know how to put a shortcut to a downloaded file, from my Mozilla downloads list, on my desktop.

    that's it.

  • Can't Download ITUNES 7.02

    I have tried everything but can't download the new itunes. I have tried uninstalling quicktime, itunes, and nothing helps. I keep getting this message: This installer cannot upgrade Quicktime 7 for Windows Public Preview. Please uninstall it first. P

  • 24/7 Active - Active database

    All: I would really appreciate any answers to this question. We are a global organizational and pressure is mounting on us to keep the operations a 24/7 operation. Our SAP instances run on HPUX 11i and Oracle 9i (9205). Maintenance is however mandate

  • Making servlets step by step....

    hi everyone well im desesperate :S im getting crazy! Step for making servlets: writing servlets ( well done ) compile the servlets ( well done ) next steps :S �? i know i have to tell the server where are the servlets and one way is to deploy, to dep

  • Error 22 - PS CS5

    I am getting this error upon trying to use any of the tools under File/Automate in the 64-bit version of PS CS5. The error showed up after I applied the latest update, but uninstalling and re-installing did not solve the problem. I do not get the err