Search xml document by example

Hi.
I'd like to create a XML documents search engine. So id like to find documents that contain elements and data like in request XML document. F.E.
there are 3 documents in the database
#1
<root>
<firstname>AAA</firstname>
<lastname>BBB</lastname>
<nickname>CCC</nickname>
</root>
#2
<root>
<firstname>AAA</firstname>
<lastname>DDD</lastname>
<nickname>EEE</nickname>
</root>
#3
<root>
<firstname>FFF</firstname>
<lastname>BBB</lastname>
<nickname>GGG</nickname>
</root>
and a request xml like
#1
<root>
<firstname>AAA</firstname>
</root>
#2
<root>
<lastname>BBB</lastname>
</root>
So, id like to get #1 and #2 documents after request #1 and #1 and #3 after request #2. If there is no <someelement> in request this mean that it's value may be ANY, and if it's empty - this element in document must be empty too.
So, the question is:
Is there any simple query for this or I should generate dynamic XPath query for each request?
Thanks.

there are different ways to parse through a xml file. you can use a SAXParser for example.
http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/SAXParser.html
you can find heaps of examples for that...
http://www.brics.dk/~amoeller/XML/programming/saxexample.html

Similar Messages

  • Search xml document

    is there any way of searching an xml document, i basically want to search the xml doc for a particular value and return its id (not sure if id is the right word)
    example:
    <root element>
    <item>
    <name>value 1<name>
    <description> example 1<description>
    <item>
    <item>
    <name>value 2<name>
    <description> example 2<description>
    <item>
    <root element>
    so for example i want to search the <name> tag for ie value 1 and the function return the item id in the file (or the contents of <description> tab). in this case the id for value1 would be 0 because of the way the dom parser creates them.
    i hope you understand what i am trying to say.
    Thanks

    there are different ways to parse through a xml file. you can use a SAXParser for example.
    http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/SAXParser.html
    you can find heaps of examples for that...
    http://www.brics.dk/~amoeller/XML/programming/saxexample.html

  • Creating a node in an XML Document

    Hi!
    i need to insert a new element in an existing xml document. for example,
    <bookinfo>
    <book>
    <bookname>A</bookname>
    <author>B</author>
    </book>
    <book>
    <bookname>C</bookname>
    <author>D</author>
    </book>
    </bookinfo>
    In this document if i want to insert another element using Xpath, say,<publisher> in <book> node, how to insert it.
    I'm using DOM parser for parsing the xml file.
    Any help to solve this issue appreciated.
    Thanks in advance.

    final class Foo {
        private static final String MARKUP =
            "<bookinfo>\n" +
              "<book isbn='1234'>\n" +
              "<bookname>A</bookname>\n" +
              "<author>B</author>\n" +
              "</book>\n" +
              "<book isbn='5678'>\n" +
              "<bookname>C</bookname>\n" +
              "<author>D</author>\n" +
              "</book>\n" +
              "</bookinfo>";
        private Foo() {
            super();
        public static final void main(final String[] args)
            throws XPathExpressionException {
            String isbn = args.length > 0 ? args[0] : "1234";
            String publisher = args.length > 1 ? args[1] : "Sample Publisher";
            Document document = ...  // Initialize somehow
            XPath xpath = XPathFactory.newInstance().newXPath();
            String expression = "//bookinfo/book[@isbn=" + isbn + "]";
            Element book = (Element) xpath.evaluate(expression, document.getDocumentElement(), XPathConstants.NODE);
            if (book == null) {
                throw new RuntimeException("Unable to find ISBN " + isbn);
            Element newPublisher = document.createElement("publisher");
            newPublisher.setAttribute("name", publisher);
            book.appendChild(newPublisher);
    }- Saish

  • How to search for a text node with a particular value in an xml document with labview

    supposing i have the following xml document:
    <head>
    <book>
    <bookname>zio</bookname>
    <author>dan</author>
    </book>
    <book>
    <bookname>the spear warrior</bookname>
    <author>britney</author>
    </book>
    <book>
    <bookname>the beard</bookname>
    <author>derrick</author>
    </book>
    </head>
    i want to search for the author of the book "the beard" using for example the V.I Get first match  of labview to access the the node with value "the beard" and then use Get next sibling  V.I  and Get node text content to get get the author of this book..so my question is how do i write the xpath expression for Get first match so as to access the node with bookname "the beard" instantyly?  am trying to minimise the use of loops because they increase the time duration,..thank you (NB:i dont want to use Get all Matched V.I because it obliges me to use a loop in order to access the name derrick and this increases the time duration for my v.i)
    Solved!
    Go to Solution.

    Since it's all text, why not use a real quick Match Pattern (or Regular Expression, but you don't need that much power here), see attached.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ
    Attachments:
    Two-stage match demo.vi ‏8 KB

  • Intermedia text search in XML document stored as CLOB

    Suppose i store an XML document as clob
    and i index it based on the tags ie
    if i have the followind table
    create table biodata (
    resume_id number primary key,
    content clob default empty_clob(),
    applicant_id number references
    applicants(id));
    and i stores various resumes in the clob (content column ) as xml document ie
    <experience_in_months> 22 </experience_in_months>
    Now if i want all the resume_id that that have experiences_in_months >= 10
    what would be the query that would fetch me this result?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by voron:
    We are storing data in XML format in an Oracle database (via CLOB). I can retrieve search results using the 'within' phrase, but am finding it hard to order them. Is there a utility or command I can use?<HR></BLOCKQUOTE>
    Maybe you should write a stored procedure (function )
    that extracts the section from your clob
    that should be sorted. Then use this function
    in the ORDER clause of your select statement.
    Andreas
    null

  • Keyword search over XML documents

    there are many open source native XML databases,and search engines that support XQuery and XPath and many of them also support full text search.
    such as:
    1- TPOX
    2- Timber
    3- DBXML
    4 - http://exist.sourceforge.net/kwic.html [http://exist.sourceforge.net/kwic.html]
    5- http://www.inf.uni-konstanz.de/dbis/basex/ [http://www.inf.uni-konstanz.de/dbis/basex/]
    6- http://xqengine.sourceforge.net/ [http://xqengine.sourceforge.net/]
    7- Lucene
    But, could you please tell me what is the alternative open source systems for the following closed systems (XRANK is a Ranked keyword search over XML documents on http://www.cs.cornell.edu/~cbotev/XRank.pdf ) and (XSeek is A Semantic XML Search Engine Using Keywords on http://xseek.asu.edu/xseekdemo.pdf )
    I posted the question on http://stackoverflow.com/questions/2921379/is-there-any-open-source-system-for-keyword-search-on-xml-documents and I have got good information , but I think some people on this forum may have more information.
    thanks.

    Well, there is a workaround to search in the xml. Open xml in FF, open the page source (Ctrl + U) and search in it.

  • Searching CLOB column of XML documents with leading wildcard - Performance

    Hi, our table has a text indexed CLOB column of XML documents and when performing a search with a leading wild card, we never retrieve any results.
    The query looks like this:
    select id from <table> where contains(columnname, '(%12345)') > 0;
    I cant even generate an explain plan from this query. I killed it after 39 minutes.
    If the query changes to:
    select id from <table> where contains(columnname, '(12345%)') > 0;
    I get an explain plan immediately with a cost=2 and when I execute the query, I get results in less than a second.
    I'd appreciate any thoughts of what I should check or what the problem might be.
    Thanks! Doug

    Can you provide a script that reproduces the case. I am unable to reproduce the problem with just some small sample data, as shown below. That means that there is nothing wrong with the syntax, but you may be having problems due to the size of your data or other parameters that have not been mentioned.
    SCOTT@10gXE> CREATE TABLE your_table (id NUMBER, columnname CLOB)
      2  /
    Table created.
    SCOTT@10gXE> insert into your_table
      2  select 1, dbms_xmlgen.getxml
      3             ('select deptno, dname,
      4                   cursor (select empno, ename
      5                        from      emp
      6                        where  emp.deptno = dept.deptno ) employee
      7               from   dept
      8               where  deptno = 10')
      9  from   dual
    10  /
    1 row created.
    SCOTT@10gXE> SELECT * FROM your_table
      2  /
            ID COLUMNNAME
             1 <?xml version="1.0"?>
               <ROWSET>
                <ROW>
                 <DEPTNO>10</DEPTNO>
                 <DNAME>ACCOUNTING</DNAME>
                 <EMPLOYEE>
                  <EMPLOYEE_ROW>
                   <EMPNO>7782</EMPNO>
                   <ENAME>CLARK</ENAME>
                  </EMPLOYEE_ROW>
                  <EMPLOYEE_ROW>
                   <EMPNO>7839</EMPNO>
                   <ENAME>KING</ENAME>
                  </EMPLOYEE_ROW>
                  <EMPLOYEE_ROW>
                   <EMPNO>7934</EMPNO>
                   <ENAME>MILLER</ENAME>
                  </EMPLOYEE_ROW>
                 </EMPLOYEE>
                </ROW>
               </ROWSET>
    SCOTT@10gXE> CREATE INDEX your_idx ON your_table (columnname)
      2  INDEXTYPE IS CTXSYS.CONTEXT
      3  /
    Index created.
    SCOTT@10gXE> EXEC DBMS_STATS.GATHER_TABLE_STATS ('SCOTT', 'YOUR_TABLE')
    PL/SQL procedure successfully completed.
    SCOTT@10gXE> SET AUTOTRACE ON EXPLAIN
    SCOTT@10gXE> select id from your_table where contains (columnname, '(%839)') > 0
      2  /
            ID
             1
    Execution Plan
    Plan hash value: 2832585188
    | Id  | Operation                   | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |            |     1 |   888 |     0   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| YOUR_TABLE |     1 |   888 |     0   (0)| 00:00:01 |
    |*  2 |   DOMAIN INDEX              | YOUR_IDX   |       |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("CTXSYS"."CONTAINS"("COLUMNNAME",'(%839)')>0)
    SCOTT@10gXE> SET AUTOTRACE OFF

  • Validating an XML document to a schema using ColdFusion

    This is something I have never tried before.  We created an XML Schema  to define XML documents we expect to receive from various entities.   When we receive the document, we would like to validate it before  processing it.  I think ColdFusion is up to this from reading the  documentation, but we have not got anything working yet.
    When we try and xmlParse() our test XML file against the XML schema we  get the following error.  When we use a web based XML validation tool  and feed it the same XML file and schema it validates just fine.
    An error occured while parsing an XML document.
    [Error] :2:6: cvc-elt.1: Cannot find the declaration of element 'pur'.
    The error occurred in D:\playground\warren\ppur_file_import.cfm: line 57
    55 :
    56 :
    57 : <cfset xmldoc = XmlParse(ExpandPath(filepath), true,  ExpandPath(validator)) />
    58 : <cfdump var="#xmldoc#">
    59 : <cfabort>
    Searching for the error has not provided me any useful hints.  Can  anybody here?

    XML SCHEMA
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
         <!-- Simple Types -->
         <xs:simpleType name="RECORD_ID">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[AaBbCc]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="REPORT_MONTH">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="(0[1-9]|1[0-2])"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="REPORT_YEAR">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="MFG_FIRMNO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{7}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="LABEL_SEQ_NO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{5}"/>
              </xs:restriction>
         </xs:simpleType>     
         <xs:simpleType name="REVISION_NO">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[A-Za-z]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="REG_FIRMNO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{7}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="GROWER_ID">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{11}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="CEDTS_IND">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[Ee]|[ ]"/>
                   <!-- needs to match E or a blank. -->
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="APPLIC_DT">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])([0-9]{2})"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="SITE_CODE">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{6}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="QUALIFY_CD">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>     
         <xs:simpleType name="PLANTING_SEQ">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="ACRE_TREATED">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{8}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="UNIT_TREATED">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[ATSCKUPatsckup]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="AMT_PRD_USED">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{10}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="UNIT_OF_MEAS">
              <xs:restriction base="xs:string">
                   <xs:pattern value="LB|OZ|GA|QT|PT|KG|GR|LI|ML"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="DOCUMENT_NO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{8}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="LINE_ITEM">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{4}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="PROCESS_DT">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{4}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="BATCH_NO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-5][0-9][0-9][0-9]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="COUNTY_CD">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-5][0-9]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="SECTION">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="TOWNSHIP">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="TSHIP_DIR">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[NSns]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="RANGE">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{2}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="RANGE_DIR">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[EWew]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="BASE_LN_MER">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[HMShms]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="AER_GND_IND">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[AFGOafgo]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="SITE_LOC_ID">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[-0-9 ]+"/>
                   <!-- Examples in files I checked
                         only had numeric characters and
                         a dash. The county contract doesn't
                         specify numeric-only, so letters may
                         be acceptable. I find no evidence of
                         any letters being used. -->
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="ACRE_PLANTED">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{8}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="UNIT_PLANTED">
              <xs:restriction base="xs:string">
                   <xs:pattern value="[ATSCKUPatsckup]"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="APPLIC_TM">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{4}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="APPLIC_CNT">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{6}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="FUME_CD">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[0-9]{4}"/>
              </xs:restriction>
         </xs:simpleType>
         <xs:simpleType name="LICENSE_NO">
              <xs:restriction base="xs:integer">
                   <xs:pattern value="[-0-9A-Za-z]{13}"/>
              </xs:restriction>
         </xs:simpleType>
         <!-- end Simple Types -->
         <!-- !!!!!!!!! Begin Abstract Types !!!!!!!!! -->
         <xs:complexType name="application_data_abs" abstract="true">
              <xs:sequence>          
                   <xs:element name="GROWER_ID" type="GROWER_ID" />                    
                   <xs:element name="CEDTS_IND" type="CEDTS_IND" />
                   <xs:element name="APPLIC_DT" type="APPLIC_DT" />     
                   <xs:element name="SITE_CODE" type="SITE_CODE" />               
                   <xs:element name="QUALIFY_CD" type="QUALIFY_CD" />
                   <xs:element name="PLANTING_SEQ" type="PLANTING_SEQ" />
                   <xs:element name="ACRE_TREATED" type="ACRE_TREATED" />                         
                   <xs:element name="UNIT_TREATED" type="UNIT_TREATED" />
                   <xs:element name="AMT_PRD_USED" type="AMT_PRD_USED" />
                   <xs:element name="UNIT_OF_MEAS" type="UNIT_OF_MEAS" />               
                   <xs:element name="DOCUMENT_NO" type="DOCUMENT_NO" />                         
                   <xs:element name="LINE_ITEM" type="LINE_ITEM" />
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="application_abs" abstract="true">
              <xs:sequence>
                   <xs:element name="key_data" type="key_data" />
                   <xs:element name="product_data" type="product_data" />
              </xs:sequence>
         </xs:complexType>
         <!-- !!!!!!!!! End Abstract Types !!!!!!!!! -->
         <!-- !!!!!!!!! Start Complex Types !!!!!!!!! -->
         <xs:complexType name="product_data">
              <xs:sequence>
                   <xs:element name="MFG_FIRMNO" type="MFG_FIRMNO" />               
                   <xs:element name="LABEL_SEQ_NO" type="LABEL_SEQ_NO"/>                         
                   <xs:element name="REVISION_NO" type="REVISION_NO" />
                   <xs:element name="REG_FIRMNO" type="REG_FIRMNO" />               
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="key_data">
              <xs:sequence>
                   <xs:element name="RECORD_ID" type="RECORD_ID" />     
                   <xs:element name="COUNTY_KEY">
                        <!--
                             The optional COUNTY_ID field would be used by
                             the Counties to include their internal
                             record identifier. This would allow DPR
                             to reference a county's internal record ID
                             in the event of data inconsistencies.
                        -->
                   </xs:element>
                   <xs:element name="REPORT_MONTH" type="REPORT_MONTH" />
                   <xs:element name="REPORT_YEAR" type="REPORT_YEAR" />
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="fileInfo">
              <xs:sequence>
                   <xs:element name="PROCESS_DT" type="PROCESS_DT" />                              
                   <xs:element name="BATCH_NO" type="BATCH_NO" />
                   <xs:element name="COUNTY_CD" type="COUNTY_CD" />
              </xs:sequence>
         </xs:complexType>     
         <xs:complexType name="mtrs_data">
              <xs:sequence>
                   <xs:element name="SECTION" type="SECTION" />
                   <xs:element name="TOWNSHIP" type="TOWNSHIP" />                                        
                   <xs:element name="TSHIP_DIR" type="TSHIP_DIR" />
                   <xs:element name="RANGE" type="RANGE" />
                   <xs:element name="RANGE_DIR" type="RANGE_DIR" />
                   <xs:element name="BASE_LN_MER" type="BASE_LN_MER" />
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="ag_application_data">
              <xs:complexContent>
                   <xs:extension base="application_data_abs">
                        <xs:sequence>                                             
                             <xs:element name="AER_GND_IND" type="AER_GND_IND" />
                             <xs:element name="SITE_LOC_ID" type="SITE_LOC_ID" />
                             <xs:element name="ACRE_PLANTED" type="ACRE_PLANTED" />
                             <xs:element name="UNIT_PLANTED" type="UNIT_PLANTED" />
                             <xs:element name="APPLIC_TM" type="APPLIC_TM" />
                             <xs:element name="FUME_CD" type="FUME_CD" />
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <xs:complexType name="nonag_application_data">
              <xs:complexContent>
                   <xs:extension base="application_data_abs">
                        <xs:sequence>                                        
                             <xs:element name="APPLIC_CNT" type="APPLIC_CNT" />
                             <xs:element name="LICENSE_NO" type="LICENSE_NO" />
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <!--- "Ag" -->
         <!--
              Type A:
              Data that would appear on individual lines
              in the old A type
              (F file type, agricultural job report)
              Type B:
              Data that would appear on individual lines
              in the old B type
              (F file type, agricultural monthly production summary)
         -->     
         <xs:complexType name="ag_application">
              <xs:complexContent>
                   <xs:extension base="application_abs">
                        <xs:sequence>                                        
                             <xs:element name="mtrs_data" type="mtrs_data" />
                             <xs:element name="application_data" type="ag_application_data" />
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <!--- "Non_Ag" -->     
         <!--
              Data that would appear on individual lines
              in the old C type
              (C file type, non-agricultural monthly summary)
         -->          
         <xs:complexType name="nonag_application">
              <xs:complexContent>
                   <xs:extension base="application_abs">
                        <xs:sequence>                                        
                             <xs:element name="application_data" type="nonag_application_data" />
                        </xs:sequence>
                   </xs:extension>
              </xs:complexContent>
         </xs:complexType>
         <!-- The individual lines of data that are transmitted. -->
         <xs:complexType name="data_lines">
              <xs:sequence>                                        
                   <xs:element name="Non_Ag" type="nonag_application" minOccurs="0" maxOccurs="unbounded"/>
                   <xs:element name="Ag" type="ag_application" minOccurs="0" maxOccurs="unbounded"/>                    
              </xs:sequence>
         </xs:complexType>
         <!-- !!!!!!!!! End Complex Types !!!!!!!!! -->
         <xs:element name="pur">     
              <xs:complexType>
                   <xs:sequence>               
                        <xs:element name="County" minOccurs="0" maxOccurs="1">
                             <!--
                                  Tag for counties to put county-specific
                                  data in (eg, their batch number, timestamp,
                                  contact info, etc)
                             -->
                        </xs:element>
                        <!-- File: information specific to the file -->               
                        <xs:element name="File" type="fileInfo" minOccurs="1" maxOccurs="1"/>
                        <!-- Data: lines of data transmitted -->
                        <xs:element name="Data" type="data_lines" minOccurs="1" maxOccurs="1"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>

  • Serializing an XML document

    Hello, I recently downloaded the Java XML Pack, which uses the Xerces2 XML Parser. A couple of questions with regards to serializing an XML document to a file:
    1) Xerces1 used the org.apache.xml.serialize.* classes to do serialization (such as shown below), but I don't see them in the Xerces2 API. Which packages take over for these in Xerces2?
    import org.apache.xml.serialize.Serializer;
    import org.apache.xml.serialize.SerializerFactory;
    import org.apache.xml.serialize.XMLSerializer;
    2) If we use the JAXP wrapper functionality to serialize instead, is the javax.xml.transform package the standard way to do this in 1.2?--from the examples I've seen searching this forum, this appears to be the case.
    Thanks,
    Glen

    If you want to output your XML to a file, say, then yes the Transformer is the way to do it now. Don't know why they did that, it's far from intuitively obvious.

  • Embedding XSL in XML document

    Hi
    I am new to this particular forum. I had some query regarding embedding XSL .
    Can we embedd the XSL stylesheet in the XML document itself.
    I searched this forum and got some similar queries but the output isn't working. Can anyone put a working example.
    I have got the following XSL stylesheet:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <body>
    <table border="1" width="100%" cellpadding="1">
    <tr bgcolor="#FFFF99">
    <th style="font-family:arial unicode ms;font-size:100%" align="center">Serial number </th>
    <th style="font-family:arial unicode ms;font-size:100%" align="center">Site number </th>
    </tr>
    <xsl:for-each select="Master/RECORD">
    <xsl:if test="SR_NO &gt; 0">
    <tr>
    <td style="font-family:arial unicode ms;font-size:80%" align="right"><xsl:value-of select="SR_NO"/></td>
    <td style="font-family:arial unicode ms;font-size:80%" align="right"><xsl:value-of select="ACR_SNO"/></td>
    </tr>
    </xsl:if>
    </xsl:for-each>
    </table>
    </body>
    </xsl:template>
    </xsl:stylesheet>
    The XML document is as below:
    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type="text/xsl" href="archivingmaster.xsl"?>
    <Master>
    <RECORD>
    <SR_NO>1</SR_NO>
    <ACRSNO>1</ACR_SNO>
    </RECORD>
    <RECORD>
    <SR_NO>2</SR_NO>
    <ACRSNO>2</ACR_SNO>
    </RECORD>
    </Master>
    Thanks in advance
    Ameya.

    I have already gone through that link and searched for this on the net. But it doesn't seem to work on my Mozilla Firefox browser.
    Can anybody put a working example if possible.
    Thanks
    Ameya.

  • UTL_DBWS, XML Document as a parameter

    I'm struggling with using a fully formed xml document as a parameter to a web service.
    Using this code I'm able to connect to the web service and sans the arg1 argument everything works.
    When I as in the code below use xmltype.toStringValue() or xmltype.toClobValue() charachters like < and > is replaced with the html encoded version (&lt; and &gt;) which does'nt work very well with the recieving web service.
    All three parameters is defined as string on the recieving web service.
    I've been searching this forum and using google, but can't find any examples doing something like this.
    Any help or pointers appreciated.
    procedure forwardToQueue is
    svc_ sys.utl_dbws.service;
    call_ sys.utl_dbws.call;
    svc_qname sys.utl_dbws.qname;
    response sys.xmltype;
    request sys.xmltype;
    utMelding sys.xmltype;
    t1 sys.xmltype;
    t2 sys.xmltype;
    doc xmldom.DomDocument;
    fListe xmldom.DOMNodeList;
    tmpL xmldom.DOMNodeList;
    fElement xmldom.domNode;
    tmp xmldom.domNode;
    meldingId strliten;
    arg0_node xmldom.domnode;
    arg0_elmt xmldom.domelement;
    arg0_text xmldom.domtext;
    arg1_node xmldom.domnode;
    arg1_elmt xmldom.domelement;
    arg1_text xmldom.domtext;
    arg2_node xmldom.domnode;
    arg2_elmt xmldom.domelement;
    arg2_text xmldom.domtext;
    child_doc xmldom.domdocument;
    main_node xmldom.domnode;
    root_node xmldom.domnode;
    root_elmt xmldom.domelement;
    x sys.xmltype;
    c varchar2(32000);
    bs_chr strmax;
    l_service sys.UTL_DBWS.service;
    l_call sys.UTL_DBWS.call;
    l_result ANYDATA;
    l_wsdl_url strmax := 'http://salah-test.sismo.local:8080/SIMSEJB/SIMSFacadeBean?wsdl';
    l_namespace strmax := 'http://salah-test.sismo.local:8080/SIMSEJB/SIMSFacadeBean';
    l_service_qname sys.utl_dbws.qname;
    begin
    procName := 'hentQueue';
    pl('*************** '||procName||' ***************');
    svc_qname := sys.utl_dbws.to_qname(null, 'SIMSFacadeBeanService');
    svc_ := sys.utl_dbws.create_service(svc_qname);
    call_ := sys.utl_dbws.create_call(svc_);
    sys.utl_dbws.set_target_endpoint_address(call_, 'http://salah-test.sismo.local:8080/SIMSEJB/SIMSFacadeBean');
    sys.utl_dbws.set_property(call_, 'SOAPACTION_USE', 'TRUE');
    sys.utl_dbws.set_property(call_, 'SOAPACTION_URI', 'sendMessage');
    sys.utl_dbws.set_property(call_, 'OPERATION_STYLE', 'document');
    x := genererSvar;
    doc := xmldom.newDOMDocument;
    main_node := xmldom.makeNode(doc);
    root_elmt := xmldom.createelement(doc, 'q0:sendMessage');
    xmldom.setattribute(root_elmt, 'xmlns:q0', 'si.sims.intern.service');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    -- Adding arg 0 as a string
    arg0_elmt := xmldom.createelement(doc, 'arg0');
    arg0_node := xmldom.appendchild(root_node, xmldom.makenode(arg0_elmt));
    arg0_text := xmldom.createtextnode(doc, '2');
    arg0_node := xmldom.appendchild(arg0_node, xmldom.makenode(arg0_text));
                   -- Adding arg 1 as a string
    arg1_elmt := xmldom.createelement(doc, 'arg1');
    arg1_node := xmldom.appendchild(root_node, xmldom.makenode(arg1_elmt));
    arg1_text := xmldom.createtextnode(doc, x.getClobVal());
    arg1_node := xmldom.appendchild(arg1_node, xmldom.makenode(arg1_text));
    -- Adding arg 2 as a string
    arg2_elmt := xmldom.createelement(doc, 'arg2');
    arg2_node := xmldom.appendchild(root_node, xmldom.makenode(arg2_elmt));
    arg2_text := xmldom.createtextnode(doc, 'false');
    arg2_node := xmldom.appendchild(arg2_node, xmldom.makenode(arg2_text));
    request := xmldom.getxmltype(doc);
    pl('Request:');
    pl(request.getStringVal());
    response := sys.utl_dbws.invoke(call_, request);
    pl('Showing respons');
    pl(response.getStringVal());
    doc := DBMS_XMLDOM.newDomDocument(response);
    sys.utl_dbws.release_call(call_);
    sys.utl_dbws.release_service(svc_);
    end forwardToQueue;

    Is the Document well defined via schema? You might be able to use the autotype
    ant task to generate a serializer.
    Otherwise, serialize the document to a string, then wrap it in <[CDATA[...]]>
    on the return. The calling app will need to understand that the string is xml,
    and then desrailize it manually.
    Mike
    "Surya" <[email protected]> wrote:
    >
    I have web service which has to retuen an XML document (org.w3c.dom.Document)
    as
    a paramter. Since this is not a supported data type for in-out paramaters,
    I will
    have to serialize and write my own converter. What is the best solution?
    Is there
    any class/library that can convert the document into String which I can
    return
    as a parameter and again get create a XML document in the client side.
    Thanks -Surya

  • Storing and searching XML in CLOBs

    Speaking to an oracle employee at the Oracle booth at JavaOne
    recently. They suggested I store XML in CLOBs
    and use the DOM or SAX to reparse the XML later as needed.
    I agreed that this was the best solution for my problem
    (which was how to manage many different XML documents using many
    different DTDs in a document management system)
    The big problem was searching this document repository
    to locate relevant information.
    This is where Intermedia seemed ideal (still does).
    It would be nice to see an example of setting this up using
    Intermedia in Oracle 8i, demonstrating how to define the
    XML_SECTION_GROUP and where to use a ZONE as opposed to a FIELD
    etc.
    Anybody care to take a shot at this ????
    For example:
    How would I define Intermedia parameters
    so that I would be able to search my CLOB
    column for records that had the <keyword>
    "aorta" and "damage" in the <caption>
    using the following
    XML (DTD implied)
    <image filename="OurImageName.gif">
    <fname>WellKnownFileName.gif</fname>
    <keyword>echocardiogram</keyword>
    <keyword>aorta</keyword>
    <caption>This is an image of the vessel damage</caption>
    </image>
    Thanks
    Thomas Bennett
    null

    Eric (guest) wrote:
    : You can't do XML structure-based searches with intermedia. You
    : can search for text within a given element, but nothing more
    : complicated than that.
    The example he gave involves exactly that -- searching for
    text within XML elements. interMedia can do this.
    : It also does not do attributes.
    Upcoming 8.1.6 version allows searching within
    attribute text. That's something like:
    dog within book@author
    We're working on attribute value sensitive search,
    more like:
    dog within book[@author = "Eric"]
    : Thomas Bennett (guest) wrote:
    : : How would I define Intermedia parameters
    : : so that I would be able to search my CLOB
    : : column for records that had the <keyword>
    : : "aorta" and "damage" in the <caption>
    : : using the following
    : : XML (DTD implied)
    : : <image filename="OurImageName.gif">
    : : <fname>WellKnownFileName.gif</fname>
    : : <keyword>echocardiogram</keyword>
    : : <keyword>aorta</keyword>
    : : <caption>This is an image of the vessel damage</caption>
    : : </image>
    begin
    ctx_ddl.create_section_group('mygrp','basic_section_group');
    ctx_ddl.add_field_section('mygrp','keyword','keyword');
    ctx_ddl.add_field_section('mygrp','caption','caption');
    end;
    create index myidx on mytab(mytxtcolumn)
    indextype is ctxsys.context
    parameters ('section group mygrp');
    select * from mytab
    where contains(mytxtcolumn, 'aorta within keyword')>0;
    options:
    * use XML section group instead of basic section group
    if your tags have attributes or you need case-sensitive
    tag detection
    * use zone sections instead of field sections if your
    sections overlap, or if you need to distinguish
    between instances. For instance, keywords. If keywords
    is a field section, then
    (aorta and echocardiogram) within keywords
    finds the document. if it is a zone section, then it
    doesn't, because they are not in the SAME instance of
    keywords.
    null

  • XPATH in a XML Document

    Hi guys, I need again your help.
    I have many xml documents and I need create a class that "search" data at this xml documents. What I can do this!?!?
    For example, I wanna get the Paul ages in the age.xml document!!!!! I wanna create a method like this:
    SearchXmlfile search = new SearchXmlFile();
    String result = search.get("/person@age[person@attribute = 'paul']"); //I pass the xpath like parameter
    Someone know What I can do this?!!?
    Just another question. When I create a transformer I set the Source and Result "Objects" (SAX, DOM or Stream). And where i set the xsl file?!!? I am reading the jwsdp tutorial and I don't understand where I configure the xsl file transformer to the transformer object!!!!
    Thanks Again.
    Giscard.

    1. For selecting nodes with an XPath expression parse with the JDom parser and select nodes with the XPath class.
    http://www.jdom.org/
    2. Set the stylesheet in the Transformer.
               DocumentBuilderFactory factory =
                DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = factory.newDocumentBuilder();
               Document document = builder.parse(new File("c:/input.xml"));
                TransformerFactory tFactory =
                    TransformerFactory.newInstance();
                StreamSource stylesource = new StreamSource(stylesheet);//Set the Stylesheet
                Transformer transformer = tFactory.newTransformer(stylesource);
                DOMSource source = new DOMSource(document);
                StreamResult result = new StreamResult(System.out);
                transformer.transform(source, result);

  • Parse XML document which have xlink/xpointer inside

    dear friends,
    There are lots of topic talking about parse xml, validating xml with schema and so on, but no one or any book talking about parsing xml document which can parse document with link inside.
    According to Mr Meggison at http://www.megginson.com/Background/
    we can do it, but he is not expert with this thing.
    For example I have 3 XML document. My main XML document, let named it A.XML have XPointer inside and this element pointing to B.XML and C.XML using xpointer. how to parse A.XML and in the same time my SAX recognized this XPointer and parse also element inside B.XML and C.XML.
    I am really grateull for any helpful information from you.
    best regards

    I think you need to look for a SAX or DOM parser that undestands XPointers and knows how to follow them to additional content.
    I have used XSLT and specified external documents to it. It knows how to read a document and in effect make a nodeset which can be searched with the XPath capabilities of XSLT.
    It sounds like you wnat an <include file="xxx"/> capability and have the parser stop reading the current file, and start reading the second file.
    That works in Schemas, but I'm unaware of any way to do it with SAX or DOM in one pass.
    It would not be too hard to process the first file, say with DOM.
    After the Document is built, go find the <include> elements, read get the attribute needed, build a new Document and merge it into the original Document in place of the <include> element.
    Is this more what you want to do?
    Dave Patterson

  • Urgent help in searching XML docs

    Hi All,
    I have started using JDOM and created a XML document after reading the contents from a text file. Now i need to implement a search facility on this XML document. The structure of my XML document is given bellow
    <Company ID="C1">
      <Name>aa</Name>
      <Address>qq</Address>
      <Contact_Person>ww</Contact_Person>
      <Designation>ee</Designation>
      <Phone>123</Phone>
      <Fax>456</Fax>
      <EMail>acd</EMail>
      <Website>axc</Website>
      <Business_Type>hfs</Business_Type>
      <Operation_Areas>khgd</Operation_Areas>
      <Other_Info>csbdcks</Other_Info>
    </Company>There are similar company nodes having information about different companies.
    The search criteria can be based on any one node e.g search companies by <Location> or <Business_Type> etc. I am planning to use XSL and pass the search parameters. Is the approach right?? Could someone guide me with some code examples .
    Thanks in advance..
    Nilotpal     

    If you want to search information in a JDom object, you can use XPath with Jaxen: http://www.jaxen.org/
    I never used Jaxen, so I can't help you.
    But with XPath you can implement many search facilities.

Maybe you are looking for