Tips for parsing xml in a shell script?

Hello,
I'm writing a shell script to extract info from an xml file to create various text files that share data in the form of custom entities declared at the top of the document (product id, name, version, copyright date, etc.). So far I'm using xmllint which is working well. I'm extracting text for my project files using xmllint --shell:
<pre style="padding-left: .75ex; padding-top: .25em; padding-bottom: .25em; margin-top: .5em; margin-bottom: .5em; margin-left: 1ex; max-width: 80ex; overflow: auto; font-size: 10px; font-family: Monaco, 'Courier New', Courier, monospace; color: #222; background: #eee; line-height: normal">echo cat lls_cd_product/plist | xmllint --noent --shell xyz.xml | sed -e '1d; $d'</pre>
This is working well, but --shell mode adds an extra line to the beginning and end which I let sed cleanup, but then I need to strip the enclosing tags as well.
Xmllint does a good job of filling in my entities with the exception of MacRoman bullet characters that I've entered as &#165;. These are just converted to the same entity in hex, &#xA5;. I suppose I can replace those with sed, but that's starting to feel kludgey.
I'm beginning to wonder if there may be a better way to do this. I'm not very familiar with XSL, but I am considering ramping up on that.
Any suggestions would be welcome.
Cole

etresoft wrote:
It may be a few hours before I get time to work on it.
Or not.
Here is your XML file:
<?xml version="1.0" encoding="UTF-8"?>
<info>
<ver>2.1.1</ver>
<tag>abc</tag>
<name>Product Name</name>
<filename>productname</filename>
<copyright>2008</copyright>
</info>
This generates the cd product file:
<?xml version="1.0"?>
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8"
doctype-system="http://www.apple.com/DTDs/PropertyList-1.0.dtd"
doctype-public="-//Apple Computer//DTD PLIST 1.0//EN"/>
<!-- You could access addition data from some other XML file. -->
<!-- <xsl:variable name="data" select="document('data.xml')/data"/> -->
<xsl:template match="info">
<plist version="1.0">
<dict>
<key>hfs-openfolder</key>
<string>.</string>
<key>hfs-volume-name</key>
<string><xsl:value-of select="name"/></string>
<key>hide-hfs</key>
<string>./{Norton,*.txt,*.exe,.inf}</string>
<key>hide-iso</key>
<string>./{PDS,*Rename,readme,.Volume*,Norton*,*icns,Run*.app,Icon*,Desktop*,TheFolder}</string>
<key>hide-joliet</key>
<string>./{PDS,*Rename,readme,.Volume*,Norton*,*icns,Run*.app,Icon*,Desktop*,TheFolder}</string>
<key>iso-volume-name</key>
<string><xsl:value-of select="tag"/></string>
<key>joliet-volume-name</key>
<string><xsl:value-of select="name"/></string>
</dict>
</plist>
</xsl:template>
</xsl:stylesheet>
and this generates the Mac read me file in XML:
<?xml version="1.0"?>
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8"/>
<!-- You could access addition data from some other XML file. -->
<!-- <xsl:variable name="data" select="document('data.xml')/data"/> -->
<xsl:template match="info">
<!-- You don't have to deal with these entities anymore. You should be
able to save this xsl file in UTF-8 format and just type in the
bullets. But the entities work too. -->
<readme_mac><xsl:value-of select="concat(name, ' ', ver)"/>
Copyright <xsl:value-of select="copyright"/>, Laureate Learning Systems¨, Inc.
Minimum System Requirements:
¥ 300 MHz or faster PowerPC, Intel or better CPU
¥ Mac OS 8.1 or later, including any Mac OS X
¥ 64 MB available RAM
¥ 60 MB available disk space
</readme_mac>
</xsl:template>
</xsl:stylesheet>
This one will output the readme in HTML:
<?xml version="1.0"?>
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="html" indent="yes" version="4.0" encoding="UTF-8"/>
<!-- You could access addition data from some other XML file. -->
<!-- <xsl:variable name="data" select="document('data.xml')/data"/> -->
<xsl:template match="info">
<!-- You don't have to deal with these entities anymore. You should be
able to save this xsl file in UTF-8 format and just type in the
bullets. But the entities work too. -->
<html>
<head>
<title><xsl:value-of select="concat(name, ' ', ver)"/></title>
</head>
<body>
<xsl:value-of select="concat(name, ' ', ver)"/>
Copyright <xsl:value-of select="copyright"/>, Laureate Learning Systems¨, Inc.
Minimum System Requirements:
300 MHz or faster PowerPC, Intel or better CPU
Mac OS 8.1 or later, including any Mac OS X
64 MB available RAM
60 MB available disk space
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Yes. I do enjoy XSL quite a bit

Similar Messages

  • Script for parsing xml data and inserting in DB

    Thank you for reading.
    I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
    I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
    Method 1
    Create or replace procedure parse_xml is 
      l_bfile   BFILE; 
      l_clob    CLOB; 
      l_parser  dbms_xmlparser.Parser; 
      l_doc     dbms_xmldom.DOMDocument; 
      l_nl      dbms_xmldom.DOMNodeList; 
      l_n       dbms_xmldom.DOMNode; 
      l_file      dbms_xmldom.DOMNodeList; 
      l_filen       dbms_xmldom.DOMNode; 
      lv_value VARCHAR2(1000); 
       l_ch      dbms_xmldom.DOMNode; 
    l_partname varchar2(100); 
    l_filename varchar2(1000); 
      l_temp    VARCHAR2(1000); 
      TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE; 
      t_tab  tab_type := tab_type(); 
    BEGIN 
      l_bfile := BFileName('DIR1', 'SoftwareParts.xml'); 
      dbms_lob.createtemporary(l_clob, cache=>FALSE); 
      dbms_lob.open(l_bfile, dbms_lob.lob_readonly); 
      dbms_lob.loadFromFile(dest_lob => l_clob,    src_lob  => l_bfile,    amount   => dbms_lob.getLength(l_bfile)); 
      dbms_lob.close(l_bfile);  
      dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY'''); 
      l_parser := dbms_xmlparser.newParser; 
      dbms_xmlparser.parseClob(l_parser, l_clob); 
      l_doc := dbms_xmlparser.getDocument(l_parser); 
        dbms_lob.freetemporary(l_clob); 
      dbms_xmlparser.freeParser(l_parser); 
      l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part'); 
        FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP 
        l_n := dbms_xmldom.item(l_nl, cur_emp); 
        t_tab.extend; 
        dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname); 
        t_tab(t_tab.last).partname := l_partname; 
        l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName'); 
        FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP 
          l_ch := dbms_xmldom.item(l_file, cur_ch); 
          lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch)); 
          if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if; 
          t_tab(t_tab.last).filename := lv_value; 
        t_tab.extend; 
       END LOOP; 
       END LOOP; 
        t_tab.delete(t_tab.last); 
      FOR cur_emp IN t_tab.first .. t_tab.last LOOP 
      if t_tab(cur_emp).partname is not null and  t_tab(cur_emp).filename is not null then 
        INSERT INTO tab_software_parts 
        VALUES 
        (t_tab(cur_emp).partname, t_tab(cur_emp).filename); 
        end if; 
      END LOOP; 
      COMMIT; 
      dbms_xmldom.freeDocument(l_doc); 
    EXCEPTION 
      WHEN OTHERS THEN 
        dbms_lob.freetemporary(l_clob); 
        dbms_xmlparser.freeParser(l_parser); 
        dbms_xmldom.freeDocument(l_doc); 
    END; 
    <TWObject className="TWObject">
      <array size="240">
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[30]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[GB]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[40]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[DE]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
      </array>
    </TWObject>

    Reposted as
    Script to parse XML data into Oracle DB

  • I need a 2 way sync tool for the mac (or a shell script and some help)

    I am looking for a way to (two way) sync a folder on my Macbook Pro with a SMB Server (aka Windows)
    I found a few paid for applications that do this, and before I buy one I thought I'd ask here and see if there are any recommendations.
    So far I've found Synk Standard and ChronoSync.
    I assume this could also be hacked together with Automator and some shell scripts, but I'm not sure how I'd do that.

    yes, Chronosync is often recommended for this kind of thing. Never heard of Synk Standard. you can also do it for free with rsync but I suggest you stick with Chronosync.

  • Mount script for ext2 - mixing applescript and shell script

    Hello
    i want to do a .app using the ScriptEditor to get my external usb-disc mounted.
    I tried ExtFS Manager before, but was not as happy with it.
    so the basic idea is some kind of mixture of apple script and bash-shell script, but im not sure how to combine it.
    shell script:
    #!/bin/sh
    sudo kextload /Library/Extensions/ext2fs.kext
    mkdir ~/usb_music/
    sudo mount -t ext2 -o nosuid,w,m=777,user /dev/disk1s5 ~/usb_music/
    sudo chmod a+rwx ~/usb_music/
    apple-script:
    on run
    try
    do shell script ""
    end try
    end run
    any ideas how to get it combined and working ?
    best regards
    fidel
    MacBookPro 15,4" 1,83 GHz   Mac OS X (10.4.8)  

    is there a way to implement it in a way that normal users can work with sudo to mount the drive ?
    kextload requires superuser privileges, so at some point some part of your script is going to need to run with elevated privileges.
    It is possible to configure sudo to allow non-admins to run any other commands. You could either allow non-admins to to run kextload or, preferably, allow them to run your shell script.
    man sudoers will give you the details on how to configure sudo to do this, which might be as simple as:
    <pre class=command>ALL  ALL=(ALL) /usr/local/bin/myscript</pre>
    This will allow all users to run /usr/local/bin/myscript as root.

  • Setting Third-Party Saxon parser for parsing xml files

    Hi,
              I wish to parse certain xhtml files using saxon parser because that serves our needs. In order to that in tomcat, I used to use the following code -
              System.getProperties().setProperty("javax.xml.parsers.SAXParserFactory","com.icl.saxon.aelfred.SAXParserFactoryImpl");
              System.getProperties().setProperty("javax.xml.transform.TransformerFactory","com.icl.saxon.TransformerFactoryImpl");
              However this does not work in Weblogic 8.1 SP5. Which means, it actually ignores the settings and uses the default parser (which fails to parse the documents).
              I noticed that in weblogic I need to include these in the weblogic-application.xml located under the application/META-INF folder. I update the file with the following -
              <xml>
              <parser-factory>
              <saxparser-factory>com.icl.saxon.aelfred.SAXParserFactoryImpl</saxparser-factory>
              <transformer-factory>com.icl.saxon.TransformerFactoryImpl</transformer-factory>
              </parser-factory>
              </xml>
              Everything was fine and the documents were parsed but for every server start up, I got an error message -
              <Apr 4, 2006 10:34:43 AM EDT> <Error> <HTTP> <BEA-101216> <Servlet: "action" failed to preload on startup in Web application: "HarvesterWeb".
              javax.servlet.UnavailableException: Parsing error processing resource path
              at com.bea.wlw.netui.pageflow.AutoRegisterActionServlet.initModuleConfig
              (AutoRegisterActionServlet.java:416)
              at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
              at com.bea.wlw.netui.pageflow.AutoRegisterActionServlet.init(AutoRegisterActionServlet.java:103)
              at javax.servlet.GenericServlet.init(GenericServlet.java:258)
              at com.bea.wlw.netui.pageflow.AutoRegisterActionServlet.init(AutoRegisterActionServlet.java:109)
              at com.bea.wlw.netui.pageflow.PageFlowActionServlet.init(PageFlowActionServlet.java:107)
              at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1094)
              at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
              at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
              at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:970)
              at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:949)
              at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:888)
              at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3430)
              at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3375)
              at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3356)
              at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:6208)
              at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:864)
              at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2134)
              at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2175)
              at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2122)
              at weblogic.management.deploy.slave.SlaveDeployer$Application.setActivation(SlaveDeployer.java:3099)
              at weblogic.management.deploy.slave.SlaveDeployer.setActivationStateForAllApplications(SlaveDeployer.java:1768)
              at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:351)
              at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:229)
              at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:136)
              at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:965)
              at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:360)
              at weblogic.Server.main(Server.java:32)
              >
              And the server needs to be restarted after every couple of hits(particularly failures).
              Also, my other applications won't deploy throwing the same stack trace.
              At the end of all this, I get this message - Not sure if they are related but
              log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester).
              log4j:WARN Please initialize the log4j system properly.
              Any ideas or anyone run into these kind of situations? Moderators, can you please help?

    Try the following.
              1. Keep the 3rd party jars in your WLS classpath and not within your ear.
              2. Create an XML Registry through admin console.
              Services->XML.
              3. Enter appropriate values for the following
              Document Builder Factory:
              SAX Parser Factory:
              Transformer Factory:
              4. Restart WLS.
              Refer to this link. http://e-docs.bea.com/wls/docs81/ConsoleHelp/domain_xmlregistrytable.html
              cheers,
              Dips

  • Writing own getLineNumber for parsing XML Schema

    I'm creating a XML Schema tool that checks that the user is creating valid Schema text.
    What I want to do is if the user has nested an element within a parent that it's not meant to. for example:
    <element name = "1">
            <element name = "2"/>
    </element>I want to return to the user the line number that the problem has occured.
    Because as far as the SAXParser is concerned this is valid XML I can't catch a SAXParseException.
    I'm using DOM to store the XML structure.
    Is there another way I can parse the document so that I can store the line number it orginially came from?
    Many thanks
    Alex

    Thats great, thanks.
    My problem now is how can I access the parent node using SAX().
    I have an arraylist for the parent of valid children, I need to check that the child node is infact one of these nodes.
    The problem being using SAX() I can access the previous node but if their are sibling nodes this will not identify the parent.
    This is the code I have so far:
    public class TestHandler extends DefaultHandler
         int lineNo = 1;
         public void startElement(String namespaceURI, String localname, String rawname, Attributes atts) throws SAXException
              SAX sax = new SAX();
              ArrayList nodes = sax.getSchemaNodes();
              for(int i = 0; i < nodes.size(); i++)
                   SchemaNode sn = (SchemaNode)nodes.get(i);
                   if(sn.getName().equals(localname))
                        System.out.println(sn.getName() + " = " + lineNo);
         public void endElement(String namespaceURI,String localname,String rawname) throws SAXException
         public void characters(char [] buf,int offset,int len)
              lineNo++;
    }Cheers Alex

  • Error while creating DocumentBuilderFactory object for parsing XML string

    When I try to execute the following statement in an EJB class,
    DocumentBuilderFactory df=DocumentBuilderFactory.newInstance();
    I get the following exception:
    javax.xml.parsers.FactoryConfigurationError: Provider org.apache.crimson.jaxp.DocumentBuilderFactoryImpl not found
    When the same statement is executed from a standalone java class, it works fine.
    The IDE used is Visual Age for Java.
    The JAXP package used is JAXP 1.0.1
    Can anybody please let me know how can we overcome this problem?
    Thanks and Regards,
    Shashi Anand B
    E-Mail : [email protected]

    javax.xml.parsers.FactoryConfigurationError: Provider
    org.apache.crimson.jaxp.DocumentBuilderFactoryImpl not
    foundI suspect that this may be due to a classpath issue and/or a Java version issue. Doe your Visual Age installation use Java 1.3? Do you have Sun Java 1.4 also installed on your system? It may be that when you are executing from a standalone Java class, that you are using the Java 1.4 runtime, which include the org.apach.crimson.* classes. Earlier version of Java do not include this, although it may be in the JAXP package.
    I think that your Visual Age IDE is configured such that the DocumentBuilderFactory is unable to find the appropriate implementation.
    I hope this helps!
    - David

  • How to syndicate XML in a shell script? [SOLVED]

    I am trying to write a script which will read http://www.weather.gov/data/current_obs/KLEX.xml and extract the temperature (<temp_c>), pressure (<pressure_mb>), and humidity (<relative_humidity>). Can anyone help me? I suspect I need to use wget...
    #!/bin/bash
    case "$1" in
    t) echo "12 °C" ;;
    p) echo "1014.7 mb" ;;
    h) echo "51%" ;;
    esac
    Last edited by tony5429 (2008-03-13 01:29:09)

    #!/bin/sh
    cd /tmp
    wget -nc http://www.weather.gov/data/current_obs/KLEX.xml 2> /dev/null
    grep -e "<temp_c>" -e "<pressure_mb>" -e "<relative_humidity>" KLEX.xml | \
    sed 's/^[ \t]*//' | sed -e 's/<[^>]*>//g'
    rm -f KLEX.xml
    The only problem is if the values change order you will have no idea which line corresponds to which value. You could run 3 grep/sed instances matching each one individually though if you want. Or you can use something fancier but I'd need to know how you intend to use these values.
    Edit: There are a few other safety checks I ignored, like did wget succeed, but you can add that in easily if you feel like it.
    Last edited by Zepp (2008-03-12 21:41:58)

  • Help for Parsing XML like HTML Document

    I have documents that start with
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    I want to process these documents with a XML Parser.Microsoft XML Parser works well with it.Can I use DOM parser in Java to process such kind of documents?
    What Jar file I need to use to access such APIs?

    Yes, XHTML is XML so you can read it with any XML parser.
    And Java already has XML parsers built in. You don't need any jar files.

  • [SOLVED]Would be grateful for help with im notification shell script

    Hi all,
    Playing with finch (a console im client), and haven't found any notification plugins for it that work the way I want.
    What I have been doing is using tail to watch the logs. As the logs are in html, I use sed to strip the html tags:
    tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* | sed -e 's#<[^>]*>##g'
    I would like to use notify-send or dzen2 to create popup windows when the log file changes, but I'm not sure how (I am not an experienced programmer).
    This, for example, does not work:
    tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* | sed -e 's#<[^>]*>##g' | while read line ; do notify-send "${line}" ; done
    Removing sed from the stream above allows notify-send to pop up notifications. How can I have the same happen with sed in there?
    Last edited by hellomynameisphil (2011-10-22 17:49:34)

    hellomynameisphil wrote:
    tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* | sed -e 's#<[^>]*>##g' | while read line ; do notify-send "${line}" ; done
    Removing sed from the stream above allows notify-send to pop up notifications. How can I have the same happen with sed in there?
    The problem here is that sed is buffering its output to improve efficiency in pipes. Try with:
    tail -n 1 -q -f ~/.purple/logs/bonjour/phinch/*/* | sed -e 's#<[^>]*>##g' -u | while read line ; do notify-send "${line}" ; done
    And should work as well
    Regards

  • Unix Shell Script :  Attribute Parsing

    I am configuring a Unix Shell Resource on my IDM system (at least, I am TRYING to configure it)
    I am creating the script for "Get User Attribute Parsing".
    Here is the script I am using :
    *<AttrParse name='ShellSample-74kfX GetUser AttrParse' createDate='0'>*
    *<collectCsvHeader idHeader='Account ID' nameHeader='Username' delim=',' trim='true' unQuote='true'/>*
    *<collectCsvLines trim='true' unQuote='true'/>*
    *<MemberObjectGroups>*
    *<ObjectRef type='ObjectGroup' id='#ID#All' name='All'/>*
    *</MemberObjectGroups>*
    *</AttrParse>*
    But, IDM keeps giving me the following error :
    Unexpected end of data preparing to parse token number 1(<collectCsvLines trim='true' unQuote='true'/>)
    Please, could anyone give me any tips?
    Thanks.

    You didn't specify if you want a total time for a portion of a shell script, or the whole script in general. If you only want to know the time of the whole shell script, just reference the linux/unix built-in variable ${SECONDS}. This variable is reset for each PID.
    I usually add these lines to the bottom of long running shell scripts (just before an exit code):
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    ((TIME = ${SECONDS} / 60))
    echo "Script ran for ${TIME} minutes. (${SECONDS} seconds total.)
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    Like I said, ${SECONDS} starts ticking from 0 when you start the script, so no need to export the variable, just reference it. The nice part is that you don't have to bother getting into sqlplus and hit the database.

  • Shell scripting for oracle DBs

    looking for good source for shell scripting for oracle DBs

    Just buy 'Classic Shell Scripting' and 'the Unix Desktop Reference' both published by O'Reilly and you have it all.
    But if you want a platform agnostic scripting language use Perl. Comes with Oracle.
    However both bash and kornshell are a lot easier compared to Perl.
    Sybrand Bakker
    Senior Oracle DBA

  • Parsing XML from a session bean

    Hi,
    I am trying to use a Sax parser for parsing xml received from a back end
    legacy system. The code is executed from a Session bean.
    Debugging learned me that the parse() method on the parser hangs the
    container without any error or exception trace. The code works fine outside
    a container.
    All help will be highly appreciated.
    Kurt

    I found out that the InputStream implementation used parsing source inside
    the container is different
    then from the one outside (other type of VM of course!). The Weblogic
    implementation blocks at the end of
    the stream, while the normal SUN JDK 1.3 returns. This is not a bug, the bug
    I found is in my proxy that allows
    the connection to the backend. This proxy allows HTTP connections, and I
    parse the XML received over HTTP.
    Regards,
    Kurt
    "Todd Karakashian" <[email protected]> wrote in message
    news:[email protected]..
    That's seems odd. Perhaps there is something going on in your document
    handler code that triggers a hang in the environment of the server.
    When you see the hang, instruct the VM to give you a thread dump (type
    control-<break> on Windows, <control>-\ (backslash) on UNIX in the
    window in which the server is running; the results are dumped to
    stderr). That will show what every thread in the server is doing. If you
    email or post the thread dump, I will take a look at it and see if I can
    see what is going on. Also, let us know which platform, VM, parser, and
    WebLogic version you are using.
    Regards,
    -Todd
    Kurt Quirijnen wrote:
    Hi,
    I am trying to use a Sax parser for parsing xml received from a back end
    legacy system. The code is executed from a Session bean.
    Debugging learned me that the parse() method on the parser hangs the
    container without any error or exception trace. The code works fine
    outside
    a container.
    All help will be highly appreciated.
    Kurt--
    Todd Karakashian
    BEA Systems, Inc.
    [email protected]

  • How to parse XML to Java object... please help really stuck

    Thank you for reading this email...
    If I have a **DTD** like:
    <!ELEMENT person (name, age)>
    <!ATTLIST person
         id ID #REQUIRED
    >
    <!ELEMENT name ((family, given) | (given, family))>
    <!ELEMENT age (#PCDATA)>
    <!ELEMENT family (#PCDATA)>
    <!ELEMENT given (#PCDATA)>
    the **XML** like:
    <person id="a1">
    <name>
         <family> Yoshi </family>
         <given> Samurai </given>
    </name>
    <age> 21 </age>
    </person>
    **** Could you help me to write a simple parser to parse my DTD and XML to Java object, and how can I use those objects... sorry if the problem is too basic, I am a beginner and very stuck... I am very confuse with SAXParserFactory, SAXParser, ParserAdapter and DOM has its own Factory and Parser, so confuse...
    Thank you for your help, Yo

    Hi, Yo,
    Thank you very much for your help. And I Wish you are there...I'm. And I plan to stay - It's sunny and warm here in Honolulu and the waves are up :)
    A bit more question for dear people:
    In the notes, it's mainly focus on JAXB,
    1. Is that mean JAXB is most popular parser for
    parsing XML into Java object? With me, definitely. There are essentially 3 technologies that allow you to parse XML documents:
    1) "Callbacks" (e.g. SAX in JAXP): You write a class that overrides 3 methods that will be called i) whenever the parser encounters a start tag, ii) an end tag, or iii) PCDATA. Drawback: You have to figure out where the heck in the document hierarchy you are when such a callback happens, because the same method is called on EACH start tag and similarly for the end tag and the PCDATA. You have to create the objects and put them into your own data structure - it's very tedious, but you have complete control. (Well, more or less.)
    2) "Tree" (e.g. DOM in JAXP, or it's better cousin JDOM): You call a parser that in one swoop creates an entire hierarchy that corresponds to the XML document. You don't get called on each tag as with SAX, you just get the root of the resulting tree. Drawback: All the nodes in the tree have the same type! You probably want to know which tags are in the document, don't you? Well, you'll have to traverse the tree and ask each node: What tag do you represent? And what are your attributes? (You get only strings in response even though your attributes often represent numbers.) Unless you want to display the tree - that's a nice application, you can do it as a tree model for JTree -, or otherwise don't care about the individual tags, DOM is not of much help, because you have to keep track where in the tree you are while you traverse it.
    3) Enter JAXB (or Castor, or ...): You give it a grammar of the XML documents you want to parse, or "unmarshall" as the fashion dictates to call it. (Actually the name isn't that bad, because "parsing" focuses on the input text while "unmarshalling" focuses on the objects you get, even though I'd reason that it should be marshalling that converts into objects and unmarshalling that converts objects to something else, and not vice versa but that's just my opinion.) The JAXB compiler creates a bunch of source files each with one (or now more) class(es) (and now interfaces) that correspond to the elements/tags of your grammar. (Now "compiler" is a true jevel of a misnomer, try to explain to students that after they run the "compiler", they still need to compile the sources the "compiler" generated with the real Java compiler!). Ok, you've got these sources compiled. Now you call one single method, unmarshall() and as a result you get the root node of the hierarchy that corresponds to the XML document. Sounds like DOM, but it's much better - the objects in the resulting tree don't have all the same type, but their type depends on the tag they represent. E.g if there is the tag <ball-game> then there will be an object of type myPackage.BallGame in your data structure. It gets better, if there is <score> inside <ball-game> and you have an object ballGame (of type BallGame) that you can simply call ballGame.getScore() and you get an object of type myPackage.Score. In other words, the child tags become properties of the parent object. Even better, the attributes become properties, too, so as far as your program is concerned there is no difference whether the property value was originally a tag or an attribute. On top of that, you can tell in your schema that the property has an int value - or another primitive type (that's like that in 1.0, in the early release you'll have to do it in the additional xjs file). So this is a very natural way to explore the data structure of the XML document. Of course there are drawbacks, but they are minor: daunting complexity and, as a consequence, very steep learning curve, documentation that leaves much to reader's phantasy - read trial and error - (the user's guide is too simplicistic and the examples too primitive, e.g. they don't even tell you how to make a schema where a tag has only attributes) and reference manual that has ~200 pages full of technicalities and you have to look with magnifying glas for the really usefull stuff, huge number of generated classes, some of which you may not need at all (and in 1.0 the number has doubled because each class has an accompanying interface), etc., etc. But overall, all that pales compared to the drastically improved efficiency of the programmer's efforts, i.e. your time. The time you'll spend learning the intricacies is well spent, you'll learn it once and then it will shorten your programming time all the time you use it. It's like C and Java, Java is order of magnitude more complex, but you'd probably never be sorry you gave up C.
    Of course the above essay leaves out lots and lots of detail, but I think that it touches the most important points.
    A word about JAXB 1.0 vs. Early Release (EA) version. If you have time, definitively learn 1.0, they are quite different and the main advantage is that the schema combines all the info that you had to formulate in the DTD and in the xjs file when using the EA version. I suggested EA was because you had a DTD already, but in retrospect, you better start from scratch with 1.0. The concepts in 1.0 are here to stay and once your surmounted the learning curve, you'll be glad that you don't have to switch concepts.
    When parser job is done,
    what kind of Java Object we will get? (String,
    InputStream or ...)See above, typically it's an object whose type is defined as a class (and interface in 1.0) within the sources that JABX generates. Or it can be a String or one of the primitive types - you tell the "compiler" in the schema (xjs file in EA) what you want!
    2. If we want to use JAXB, we have to contain a
    XJS-file? Something like:In EA, yes. In 1.0 no - it's all in the schema.
    I am very new to XML, is there any simpler way to get
    around them? It has already take me 4 days to find a
    simple parser which give it XML and DTD, then return
    to me Java objects ... I mean if that kind of parser
    exists....It'll take you probably magnitude longer that that to get really familiar with JAXB, but believe me it's worth it. You'll save countless days if not weeks once you'll start developing serious software with it. How long did it take you to learn Java and it's main APIs? You'll either invest the time learning how to use the software others have written, or you invest it writing it yourself. I'll take the former any time. But it's only my opinion...
    Jan

  • How to use encoded password in shell script ?

    Hi everybody,
    For make a load file in oracle table, I'm using a LKM File to Oracle updatding with a sqlldr (shell script).
    My problem is very simple : For security reason in this shell-script , I don't want to see in clear the password of the Oracle user for database connection. Is it possible and how do it ?
    Thanks in advance

    Hi-
    Yes it is possible by the way of KM custamization, You need to modify LKM call sqlldr via jython step to pass the user info and password as variable instead of ODI method. Try this command in your KM step:
    userid=#GLOBAL.user/#GLOBAL.psw
    Hope this will work for you.
    Thanks,
    Saravanan Rajavel

Maybe you are looking for

  • How to create a VISA resource without "VISA FIND" or Serial Poll

    I'm very new to LabVIEW and my experience so far with GPIB/VISA is to pass a GPIB address (from user control) to a C# function I created.  The function will build the correct VISA resource string, and try to connect using a message-based session one

  • Do not upgrade until an update comes!

    upgrade is the worst mistake i could ever make. my mac is acting stupid all the time. wifi connectivity problems. finder has issue connecting to network drive. internet stops working. have to restart mac each time to solve the issue. anyone has any s

  • Workflow and POWL integration for Travel Request / Approval

    HI, We are on EHP7 and using POWL  for different kind of Approvals. POWL is working good for Leave Approval and we have used Workflow Task ID as : TS12300097 / TS12300116, and all leave request appearing in POWL for manager and approving them. Now we

  • Create customer master in Web dynpro abap

    Hi Gurus, i'm new to web dynpro abap... My requirements is given below... which is the standard BAPI for create customer master data... then how to call workflow in web dynpro application without using portal server (uwl)... please reply as soon as p

  • After Effects, Final Cut Pro HD, and QuickTime 7

    Hello friends, I just wanted to point out a problem I have experienced with QuickTime 7 when using After Effects and Final Cut Pro HD. If this has already been covered by someone else on the forum, please forgive my unnecessary post. I am used to wor