Parsing HTML with RegExp

I have loaded a .html file and want to parse some variables. I need to search the html for a table with the ID of "formRedirNormalRadios", then parse that table again. In short, this html:
<more html>
<td id="formRedirNormalRadios">
<input type="radio" name="choice1" value="1" onclick="controlRedirNormal()" checked="checked" />
Option 1<br>
<input type="radio" name="choice1" value="2" onclick="controlRedirNormal()" checked="checked" />
Option 2<br>
<input type="radio" name="choice1" value="3" onclick="controlRedirNormal()" checked="checked" />
Option3
</td>
<also some more html>
would have to result in this variable:
Array = [formRedirNormalRadios, 1, checked, 2, checked, 3, checked]

Anyway I don't know if in the future the org.w3c.dom
package will be implemented as standard in java. Does
anyone know?Not only in the future, in the past as well. It has been part of Java since the 1.3 release.
I've got the org.w3c.dom package from rt.jar in the
jre directory.
Is the package downloadable elsewhere?

Similar Messages

  • JEditorPane parsing HTML

    Hi all,
    I am using JEditorPane and it's ability to parse HTML, which although is relatively old and crusty is certainly all I need for the job.
    Now, I understand there is a chain of classes involved in taking my .html file and turning popping into a something we can see in a JEditorPane. For example, an img tag, is picked up by HTMLEditorKit and turned into an ImageView for display purposes.
    I want to do the following: I have subclassed HTMLEditorKit, and have overridden the HTMLFactory (although at the moment it just defers everything to super). I want to be able to pick out all of the html comment tags as they go through the HTMLEditorKit :
    <!-- hey hey this is a comment -->... and get to the comment text, "hey hey this is a comment", as a Java string. However I've been digging around with Element for hours now and although my HTMLFactory correctly digs out the comments from the rest of the elements:
    else if (kind == HTML.Tag.COMMENT)
                        {System.out.println("I found a comment but don't know what it said!!");... as you can see, I don't know how to get to the comment text itself.
    The reason why I want access to the comment text is that I want to supplement the HTML code a little bit and add something in the comment that will affect the way it is rendered when I read it depending on the comment - so there's the reason if curious.
    Any help, and I do mean anything at all, would be much appreciated, as this is the last obstacle in my path to getting this thing working :)
    Thanks for your time!
    - Peter

    Here is some old code I have lying around that attempts to iterate through all the elements. If I remember correctly the comment text is found in the AttributeSet of the element:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    class GetHTML
        public static void main(String[] args)
            EditorKit kit = new HTMLEditorKit();
            Document doc = kit.createDefaultDocument();
            // The Document class does not yet handle charset's properly.
            doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
            try
                // Create a reader on the HTML content.
                Reader rd = getReader(args[0]);
                // Parse the HTML.
                kit.read(rd, doc, 0);
                System.out.println( doc.getText(0, doc.getLength()) );
                System.out.println("----");
                // Iterate through the elements of the HTML document.
                ElementIterator it = new ElementIterator(doc);
                Element elem = null;
                while ( (elem = it.next()) != null )
                    AttributeSet as = elem.getAttributes();
                    System.out.println( "\n" + elem.getName() + " : " + as.getAttributeCount() );
                    if ( elem.getName().equals( HTML.Tag.IMG.toString() ) )
                        Object o = elem.getAttributes().getAttribute( HTML.Attribute.SRC );
                        System.out.println( o );
                    Enumeration enum = as.getAttributeNames();
                    while( enum.hasMoreElements() )
                        Object name = enum.nextElement();
                        Object value = as.getAttribute( name );
                        System.out.println( "\t" + name + " : " + value );
                        if (value instanceof DefaultComboBoxModel)
                            DefaultComboBoxModel model = (DefaultComboBoxModel)value;
                            for (int j = 0; j < model.getSize(); j++)
                                Object o = model.getElementAt(j);
                                Object selected = model.getSelectedItem();
                                if ( o.equals( selected ) )
                                    System.out.println( o + " : selected" );
                                else
                                    System.out.println( o );
                    if ( elem.getName().equals( HTML.Tag.SELECT.toString() ) )
                        Object o = as.getAttribute( HTML.Attribute.ID );
                        System.out.println( o );
                    //  Wierd, the text for each tag is stored in a 'content' element
                    if (elem.getElementCount() == 0)
                        int start = elem.getStartOffset();
                        int end = elem.getEndOffset();
                        System.out.println( "\t" + doc.getText(start, end - start) );
            catch (Exception e)
                e.printStackTrace();
            System.exit(1);
        // Returns a reader on the HTML data. If 'uri' begins
        // with "http:", it's treated as a URL; otherwise,
        // it's assumed to be a local filename.
        static Reader getReader(String uri)
            throws IOException
            // Retrieve from Internet.
            if (uri.startsWith("http:"))
                URLConnection conn = new URL(uri).openConnection();
                return new InputStreamReader(conn.getInputStream());
            // Retrieve from file.
            else
                return new FileReader(uri);
    }To test it just use:
    java GetHTML somefile.html

  • Parsing HTML documents

    I am trying to write an application that uses a parsed html document to perform some data retrieval. The problem that I am having is that the parser in JDK1.4.1 is unable to completely parse the document correctly. Some fields are skipped as well as other problems. I believe it has to do with the html32.bdtd. Is there a later version?

    Parsing a HTML document is a huge task, you shouldn't do it yourself but instead javax.text.html and javax.text.html.parser already provide almost everything you ever need

  • Parsing HTML files

    Hello,
    I have a question about parsing HTML files. Usually when I get an HTML file and I need to find all the text in it I do this. This stuff just collects all of the hyperlinks and ignores all the html tags just keeping the actual text. It's fine for smaller files but occasionally I'll hit a large online text file and it will work but its way to slow for large files. I don't need to do all of this HTML tag stripping however for text files. Is there a way to still grab all the text without doing any tag searching to make it faster?
    thanks,
    private void find() throws IOException
            //Really slow for large text files.  Need a way to just use a regular scanner on an internet text file
            new ParserDelegator().parse(new InputStreamReader(myBase.openStream()),
                    new ParserListener(),
                    true); 
         * Inner class for processing all "<a href.."> tags when reading a base URL.
        private class ParserListener extends HTMLEditorKit.ParserCallback
            final String IGNORED_LINKS = "^(http|mailto|\\W).*";
            public void handleStartTag (HTML.Tag t, MutableAttributeSet a, int pos)
                if (t == HTML.Tag.A)
                    String href = (String)(a.getAttribute(HTML.Attribute.HREF));
                    //System.out.println(href);
                    //System.out.println(href.matches(IGNORED_LINKS) + "\t" + href);
                    if (! (href == null || href.matches(IGNORED_LINKS)) && !myURLs.contains(href))
                        myURLs.add(href);
                //TODO fix
                if (t == HTML.Tag.TITLE)
                    String title = (String) (a.getAttribute(HTML.Attribute.TITLE));
                    if (!(title == null))
                        myTitle = title;
                    else myTitle = "No title was found";
            public void handleText (char[] data, int pos)
                myText.append(" ");
                myText.append(data);
        }

    JFactor2004 wrote:
    My question is. If I know an html file is actually just a txt fileThis isn't a question. HTML files are text by definition.
    is it possible to look through it (maybe use something similar to a regular scanner) without doing anything with html.That depends on what you mean by "doing something with HTML". You can certainly read it one line at a time.

  • Parsing HTML from Google API results

    Hello,
    I just downloaded the Google API (http://www.google.com/apis) and I am trying to parse the HTML content which is returned so that it can be displayed in a TextArea or some other GUI component.
    Here are my questions:
    1. Is there a Java class that can parse HTML and display it correctly?
    2. If not, are there are third party, prefabably free Java components that can do that?
    3. Has anyone tried out the Google API? Any interesting applications?
    Thank you.
    Hanxue

    To convert plain text to html, you can parse the text with a simple code like this
    1.
    String inputText = getInputText(); //
    StringBuffer HTMLOutputText = new StringBuffer();
    java.util.StringTokenizer st = new java.util.StringTokenzier(inputText, "\n\r");
    while ( st.hasMoreTokens() ) {
    HTMLOutputText.append(st.nextToken());
    HTMLOutputText.append("<br>");
    /// insert the top level HTML tags
    HTMLOutputText.insert(0, "<HTML> <HEAD><TITLE> Some Title</TITLE></HEAD> <BODY>");
    HTMLOutputText.insert( HTMLOutputText.getLength(), "</BODY> </HTML>" );
    2. even simpler, but as far as I know it doesn't display right in a JEditorPane
    String inputText = getInputText();
    inputText = "<HTML> <HEAD><TITLE> Some Title</TITLE></HEAD> <BODY> <PRE> <TT>" +
    + inputText + "</TT></PRE></BODY> </HTML>";

  • Could not parse html cannot be top level tag

    hi
    i have installed the siteminder webagent in sunone server, i am trying to call my first page (index.jsp) it contains the following jsp code
    <jsp:useBean id="helpBroker" class="javax.help.ServletHelpBroker" scope="session" />
    <%@ taglib uri="/WEB-INF/jhlib.tld" prefix="jh" %>
    <jh:validate helpBroker="<%= helpBroker %>" helpSetName="<%= strContext %>" />
    (here strContext is the delphi.hs file)
    then it's giving the "Could not parse html cannot be top level tag"
    error in servers log if i comment <jh:validate helpBroker="<%= helpBroker %>" helpSetName="<%= strContext %>" /> line then everything working fine
    can anybody suggest what is the error ?

    Could be your hs file inside your firewall configuration. Check whether you can able to assess hs with different session of your browser.

  • Generate XML report then display like HTML with specified formate

    Hello,friends
    I want to generate XML report then use XSL to parse it,report will display like HTML with specified formate like attachment,any ideas?
    Thank you
    Alb

    Hi Ray,
    I don't why I can not upload any format picture,so I listed the display as below:
    Test Result                                                                                                  Company Logo
    SN                   1111                                                                                     User                          Operator
    Status              Fail                                                                                       Factory                     SE
    Product            xxx                                                                                       Tester                        xxx
    Start time         xxx                                                                                        Line                          xxx 
    Test time          xxx
    NAME                               STATUS           VALUE                          LOW               HIGH                   RULE
    1.0 Pass/Fail     Test           Passed             True                             True                                             EQ 
    2.0 Less than    Test            Failed               15                                10                                                LT
    3.0 String Value Test           Passed          A string from the limit file   A string
                                                           End of Report
    Could you give me some suggestions?
    Thanks a lot
    Alb

  • Parsed HTML/SSI not working in Web Server 7 on Ubuntu Server 9.10

    Please help. I have SJSWS 7.0u6 on Ubuntu Server 9.10. The HTML parsing is set to parse all HTML files.
    My HTML code is:
    <body>
      <!--#include file="includes/corner.html"-->
      <div id="maincontent">
         <!--#echo var="DATE_GMT"-->
      </div>
    </body>I added the echo command later to rule out an error with my include file. I even took out the include command to rule it out completely. If I "view/page source" from firefox I allways get the code as it is above in its origonal form. The server is completely ignoring the include and the echo.
    In the virtual server settings under content handling / Parsed HTML/SSI I have tried "all HTML" and "executable HTML". Both return the same result, which is no parsing whatsoever. The log is set to "finest" and so far no errors have come up. Please tell me what I am doing wrong, did I miss a step, overlook some extra settings?
    I am happy to provide more detail. Just let me know what you need to see.
    Thank you.
    update: I tested another bare bones html and got the same results, no parsing.
    Seen here : [http://kenbuxton.net/test.html]
    Edited by: Ken_Buxton on Nov 17, 2009 7:53 PM

    Deploy the configuration? Is there something beyond clicking save and restarting the instance? I checked the server.xml config file and the log level was at "info" even though I set it for "finest" in the GUI. I am now getting the finest details in the logs after I changed the server.xml file manualy. Here is what I am getting for test.html. ...
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, process-uri-objects reports: processing objects for URI /test.html
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, process-uri-objects reports: processing object name="default"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" Directive="AuthTrans" magnus-internal="1" returned -2 (REQ_NOACTION)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="ntrans-j2ee" name="j2ee" Directive="NameTrans"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="ntrans-j2ee" name="j2ee" Directive="NameTrans" returned -2 (REQ_NOACTION)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="pfx2dir" from="/mc-icons" dir="/sun/webserver7/lib/icons" name="es-internal" Directive="NameTrans"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="pfx2dir" from="/mc-icons" dir="/sun/webserver7/lib/icons" name="es-internal" Directive="NameTrans" returned -2 (REQ_NOACTION)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="uri-clean" Directive="PathCheck"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="uri-clean" Directive="PathCheck" returned 0 (REQ_PROCEED)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="find-pathinfo" Directive="PathCheck"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="find-pathinfo" Directive="PathCheck" returned -2 (REQ_NOACTION)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="find-index-j2ee" Directive="PathCheck"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="find-index-j2ee" Directive="PathCheck" returned -2 (REQ_NOACTION)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="find-index" index-names="index.html,home.html,index.jsp" Directive="PathCheck"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="find-index" index-names="index.html,home.html,index.jsp" Directive="PathCheck" returned -2 (REQ_NOACTION)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="type-j2ee" Directive="ObjectType"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="type-j2ee" Directive="ObjectType" returned 0 (REQ_PROCEED)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="type-by-extension" Directive="ObjectType"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="type-by-extension" Directive="ObjectType" returned 0 (REQ_PROCEED)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="force-type" type="text/plain" Directive="ObjectType"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="force-type" type="text/plain" Directive="ObjectType" returned 0 (REQ_PROCEED)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing method="(GET|HEAD|POST)" type="*~magnus-internal/*" fn="send-file" Directive="Service"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: method="(GET|HEAD|POST)" type="*~magnus-internal/*" fn="send-file" Directive="Service" returned -1 (REQ_ABORTED)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="error-j2ee" Directive="Error"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="error-j2ee" Directive="Error" returned -2 (REQ_NOACTION)
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: executing fn="flex-log" Directive="AddLog"
    [19/Nov/2009:10:48:37] finest ( 6266): for host 174.17.99.6 trying to GET /test.html, func_exec reports: fn="flex-log" Directive="AddLog" returned 0 (REQ_PROCEED)

  • Major Problem with regExp.exec and regExp.test

    I'm a programmer, and I'm using regExp's to simplify my life in a chat thing.
    Basically, ":blue:" in a chat will essentially be replaced with "<span style='color:blue;'>".
    because there can be all sorts of colors, I can't use replace.
    Instead, I used regExp.exec(string). However, there is a major bug where every other time, the regExp.exec returns null even if there IS a match.
    If the chat is ":blue:", the response will alternate as :blue:,null,:blue:,null,etc.
    If the chat is ":blue: :red:" (e.g. two color blocks) the response will go :blue:,null,null,:blue:,null,null and so on.
    Basically, if there are 'x' color blocks defined, the .exec will work every x+1 times, and the other times it will not find a match.
    this also happens with regExp.test.
    I have gone through my code hundreds of times, and finally, I decided to run it in Opera. It works PERFECTLY fine. even in IE, it works. So i had to assume it was some bug with Firefox.
    I hope this question catches the attention of the MOZILLA DEVELOPERS, as this is huge.
    I'm not sure if it's just me. However, I have uploaded an html file onto http://jsbattle.tablocks.com/Untitled-1.html (the subdomain had a different purpose, but i figured i would put it here), and it will alert :blue: and null (at least for me). You can view the source code.
    An important note is that this .exec and .test glitch only happens inside functions. for example, regExp.exec twice just in a script tag will run fine, but while in a function abc() {regExp.exec} and executing abc(); abc(); it'll glitch out.
    I have not run extensive tests to see when this glitch occurs, this is all I know.
    Please help, Mozilla Developers. And if anyone knows how to contact the Mozilla Developers, tell me, or address them of this issue.

    Ok ... it's the 'g' flag but with IE don't occours

  • I have made a webpage in HTML with several links to JPGs / GIFs. The text matter opens perfectly but not the images. Please help me

    I have made a web page in HTML with several links to JPGs / GIFs. While text matter opens up perfectly, but not the images. Please help me.
    == This happened ==
    Every time Firefox opened
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; CTS Version; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

    URL of that web page?

  • SAX Parser Validation with Schemas (C, C++ and JAVA)

    We are currently using the Oracle XML Parser for C to parse and validate XML data using the SAX parser interface with validation turned on. We currently define our XML with a DTD, but would like to switch to schemas. However, the Oracle XML Parser 9.2.0.3.0 (C) only validates against a DTD, not a schema when using the SAX interface. Are there plans to add schema validation as an option? If so, when would this be available? Also, the same limitation appears to be true for C++ and JAVA. When will any of these provide SAX parsing with schema validation?
    Thanks!
    John

    Will get back to you after checked with development team...

  • Parsing HTML characters (e.g. &nbsp)

    Hi
    Apologies if I'm missing something obvious, I haven't been able to find an answer searching the API or Forums...
    I'm parsing HTML documents (currently as Strings) to extract certain information. Is there an easy way to replace all special HTML characters such as   < etc. to a space or < respectively without having to do a string replace on every possible HTML character?
    I know there's an HTML parser in swing but that seems to be geared towards creating an HTML editor.
    Any help would be appreciated!

    There are also a number of open source or shareware programs, such as TidyHTML, that clean-up and parse existing HTML. Check out Sourceforge or www.downloads.com.
    - Saish

  • Problem parsing XML with schema when extracted from a jar file

    I am having a problem parsing XML with a schema, both of which are extracted from a jar file. I am using using ZipFile to get InputStream objects for the appropriate ZipEntry objects in the jar file. My XML is encrypted so I decrypt it to a temporary file. I am then attempting to parse the temporary file with the schema using DocumentBuilder.parse.
    I get the following exception:
    org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element '<root element name>'
    This was all working OK before I jarred everything (i.e. when I was using standalone files, rather than InputStreams retrieved from a jar).
    I have output the retrieved XML to a file and compared it with my original source and they are identical.
    I am baffled because the nature of the exception suggests that the schema has been read and parsed correctly but the XML file is not parsing against the schema.
    Any suggestions?
    The code is as follows:
      public void open(File input) throws IOException, CSLXMLException {
        InputStream schema = ZipFileHandler.getResourceAsStream("<jar file name>", "<schema resource name>");
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = null;
        try {
          factory.setNamespaceAware(true);
          factory.setValidating(true);
          factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
          factory.setAttribute(JAXP_SCHEMA_SOURCE, schema);
          builder = factory.newDocumentBuilder();
          builder.setErrorHandler(new CSLXMLParseHandler());
        } catch (Exception builderException) {
          throw new CSLXMLException("Error setting up SAX: " + builderException.toString());
        Document document = null;
        try {
          document = builder.parse(input);
        } catch (SAXException parseException) {
          throw new CSLXMLException(parseException.toString());
        }

    I was originally using getSystemResource, which worked fine until I jarred the application. The problem appears to be that resources returned from a jar file cannot be used in the same way as resources returned directly from the file system. You have to use the ZipFile class (or its JarFile subclass) to locate the ZipEntry in the jar file and then use ZipFile.getInputStream(ZipEntry) to convert this to an InputStream. I have seen example code where an InputStream is used for the JAXP_SCHEMA_SOURCE attribute but, for some reason, this did not work with the InputStream returned by ZipFile.getInputStream. Like you, I have also seen examples that use a URL but they appear to be URL's that point to a file not URL's that point to an entry in a jar file.
    Maybe there is another way around this but writing to a file works and I set use File.deleteOnExit() to ensure things are tidied afterwards.

  • Importing HTML with Javascript

    Hi folks,
    I have multiple (but simple) HTML forms that need to be imported as they are. Basically, I want to avoid the work of editing each button's Javascript manually in Acrobat, so I have the form ready in HTML with some JavaScript. Each form button has an onClick event calling the function below. The form works well in a browser, but, unfortunately, when I try to import it, the Javascript embedded in the page header disappears and the buttons do not work as programmed.
    Is there anyway to import the HTML *WITH* the Javascript?
    Here is the embedded Javascript code (pretty simple):
    <head>
    <script type="text/javascript">
    function DisplayCost(){
    var numPass = 0;
    var numTIDS = 0;
    var numExp = 0;
    var amtPass = 0;
    var amtTIDS = 0;
    var amtExp = 0;
    var amtTotal = 0;
    for(j=1; j <= 4; j++)
    tester = document.batch.elements["a" + j];
    exp_tester = document.batch.elements["b" + j];
    for( i = 0; i < tester.length; i++ ){
      if( tester[i].checked == true ){
    //   alert(tester[i].value)
       if(tester[i].value == "35") { numPass += 1; amtPass += parseInt(tester[i].value);
                if (exp_tester.checked == true) { numExp += 1; amtExp += parseInt(exp_tester.value);}}
       if(tester[i].value == "55") { numTIDS += 1; amtTIDS += parseInt(tester[i].value);
    if (exp_tester.checked == true) { numExp += 1; amtExp += parseInt(exp_tester.value);}}
       if(tester[i].value == "0") {exp_tester.checked=false}
    if(document.getElementByName('numPass') != null) { document.getElementByName('numPass').value = numPass;
           document.getElementByName('amtPass').value = amtPass; }
    if(document.getElementByName('numTIDS') != null) { document.getElementByName('numTIDS').value = numTIDS;
           document.getElementByName('amtTIDS').value = amtTIDS;}
    document.getElementByName('numExp').value = numExp;
    document.getElementByName('amtExp').value = amtExp;
    document.getElementByName('amtTotal').value = amtPass + amtTIDS + amtExp;
    </script>
    </head>
    Any help wuld be much appreciated.
    Regards,
    CodeChaser

    As it has already been said, there are fundamental differences between HTML "documents" and PDF documents. This also applies to JavaScript. Acrobat JavaScript and web browser JavaScript have things in common, and that is called the "Core" (get Flanagan's JavaScript, the Definitve Guide, published by O'Reilly, and you will see very clearly what objects etc. are relevant, and what not. Also, the document object model in PDF and in HTML are fundamentally different. And the field events are fundamentally different as well (as there is no onClick event in PDF, but mouseUp is used for clicking.
    What you can do, if you develop both, HTML forms and PDF forms, is to separate everything user interface-related from the raw (core) functions. The core functions can be used in either place, if their arguments are neutral, and you define them accordingly in your respective documents.
    You also can create your HTML form, and then get it into Acrobat, using WebCapture. The fields will be created, as well as labels etc. You will nevertheless rename your fields, in order to make them usable. Adding JavaScript to the appropriate events will be rather simple and straightforward.
    It would really be worthwile to have a closer look at the Acrobat JavaScript documentation (which is part of the Acrobat (X) SDK, downloadable from the Adobe website.
    For heavy duty application, you might look at a rather high-end forms design tool, OneForm Plus by Amgraf, which does create PDF forms and HTML forms from the same document, and is pretty good when it comes to the look of the forms. It also creates back-end code which is used to process submitted data. It is then also possible to have hybrid workflows when data gets displayed in PDF, and in HTML in the subsequent step and vice versa.
    Hope this can help.
    Max Wyss.

  • Printing HTML with Java Printing Service(JDK1.4 beta)

    Hi there!
    I'm currently checking out the new Java Printing Service (JPS) in the new JDK1.4 beta. This looks like a very promising printing API, with amongst others printer discovery and support for MIME types - but I have some problems with printing HTML displayed in a JEditorPane.
    I'm developing an application that should let the user edit a (HTML)document displayed in a JEditorPane and the print this document to a printer. I have understood that this should be peace-of-cake using the JPS which has pre-defined HTML DocFlavor amongst others, in fact here is what Eric Armstrong says on Javaworld (http://www.javaworld.com/javaone01/j1-01-coolapis.html):
    "With JPS, data formats are specified using MIME types, for example: image/jpeg, text/plain, and text/html. Even better, the API includes a formatting engine that understands HTML, and an engine that, given a document that implements the Printable or Pageable interface, generates PostScript. The HTML formatting engine looks particularly valuable given the prevalence of XML data storage. You only need to set up an XSLT (eXtensible Stylesheet Language Transformation) stylesheet, use it to convert the XML data to HTML, and send the result to the printer."
    After one week of reasearch I have not been able to do what Armstrong describes; print a String that contains text of MIME type text/html.
    I have checked the supported MIMI types of the Print Service returned by PrintServiceLookup.lookupDefaultPrintService(). This is the result:
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(MediaSizeName.ISO_A4);
    aset.add(new Copies(2));
    PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor,aset);
    if (service.length > 0) {
    System.out.println("Selected printer " + service[0].getName());
    DocFlavor[] flavors = service[0].getSupportedDocFlavors();
    for (int i = 0;i<flavors.length;i++) {
    System.out.println("Flavor "+i+": "+flavors.toString());
    Selected printer \\MUNIN-SERVER\HP LaserJet 2100 Series PCL 6
    Flavor 0: image/gif; class="[B"
    Flavor 1: image/gif; class="java.io.InputStream"
    Flavor 2: image/gif; class="java.net.URL"
    Flavor 3: image/jpeg; class="[B"
    Flavor 4: image/jpeg; class="java.io.InputStream"
    Flavor 5: image/jpeg; class="java.net.URL"
    Flavor 6: image/png; class="[B"
    Flavor 7: image/png; class="java.io.InputStream"
    Flavor 8: image/png; class="java.net.URL"
    Flavor 9: application/x-java-jvm-local-objectref; class="java.awt.print.Pageable"
    Flavor 10: application/x-java-jvm-local-objectref; class="java.awt.print.Printable"
    As you can see there is no support for text/html here.
    If anyone has a clue to what I'm missing here or any other (elegant, simple) way to print the contents of a JEditorPane, please speak up!
    Reply to: [email protected] or [email protected] or here in this forum

    Since you have 'printable' as one of your flavors, try this using a JTextPane (assuming you can dump your HTML into a JTextPane, which shouldn't be a big problem)...
    1. Have your JTextPane implement Printable
    ie. something like this:
    public class FormattedDocument extends JTextPane implements Printable 2. Read your HTML into the associated doc in the text pane.
    3. Implement the printable interface, since you have it as one of your available flavors (I'd imagine everybody has printable in their available flavors). Something like this:
    public int print(Graphics g, PageFormat pf, int pageIndex) {
            Graphics2D g2 = (Graphics2D) g;
            g2.translate((int)pf.getImageableX(), (int)pf.getImageableY());
            g2.setClip(0, 0, (int)pf.getImageableWidth(), (int)pf.getImageableHeight()); 
            if (pageIndex == 0)
                setupPrintView(pf);
            if (!pv.paintPage(g2, pageIndex))
                return NO_SUCH_PAGE;
            return PAGE_EXISTS;
        }Here's my setupPrintView function, which is executed once on page 0 (which still needs some polishing in case I want to start from page 5). It sets up a 'print view' class based on the root view of the document. PrintView class follows...
    public void setupPrintView(PageFormat pf) {
    View root = this.getUI().getRootView(this);
            pv = new PrintView(this.getStyledDocument().getDefaultRootElement(), root,
                               (int)pf.getImageableWidth(), (int)pf.getImageableHeight());Note of obvious: 'pv' is of type PrintView.
    Here's my PrintView class that paints your text pane line by line, a page at a time, until there is no more.
    class PrintView extends BoxView
        public PrintView(Element elem, View root, int w, int h) {
            super(elem, Y_AXIS);
            setParent(root);
            setSize(w, h);
            layout(w, h);
        public boolean paintPage(Graphics2D g2, int pageIndex) {
            int viewIndex = getTopOfViewIndex(pageIndex);
            if (viewIndex == -1) return false;
            int maxY = getHeight();
            Rectangle rc = new Rectangle();
            int fillCounter = 0;
            int Ytotal = 0;
            for (int k = viewIndex; k < getViewCount(); k++) {
                rc.x = 0;
                rc.y = Ytotal;
                rc.width = getSpan(X_AXIS, k);
                rc.height = getSpan(Y_AXIS, k);
                if (Ytotal + getSpan(Y_AXIS, k) > maxY) break;
                paintChild(g2, rc, k);
                Ytotal += getSpan(Y_AXIS, k);
            return true;
    // find top of page for a given page number
        private int getTopOfViewIndex(int pageNumber) {
            int pageHeight = getHeight() * pageNumber;
            for (int k = 0; k < getViewCount(); k++)
                if (getOffset(Y_AXIS, k) >= pageHeight) return k;
            return -1;
    }That's my 2 cents. Any questions?

Maybe you are looking for

  • Form created in Microsoft Frontpage?

    Hello, I am attempting to fix a form using Dreamweaver.  The form is located at the top-right corner of http://www.imagecandyusa.com The code for the form is as follows: <form method="POST" action="_vti_bin/shtml.exe/index.htm" onSubmit="" name="IC_h

  • Stock transfer Order Return process

    Dear Expert, We are using plant to plant stock transfer for semi fineshed and finished materials. We are using STO with delivery Need you help in getting solution for following scenarion. 1. STO creating. 2. Delivery created against STO 3. Goods Move

  • Sld settings for idoc to idoc

    hi experts, for the idoc to idoc scenrio (not making use of BPM) I have 2 business systems in sld which will be referring to the two r/3 systems. suppose bus_system1 has logical system name as logsys1 for server1 suppose bus_system2 has logical syste

  • Pages won't work for Network Users

    We have a lab of 16 computers at one of our schools.  We are using iWork '09 and the students all have networked accounts (10.6.4 or 10.6.8 machines connecting to a 10.6.8 server).  Recently, most of the students have been unable to open Pages when l

  • I have the l latest iMac with the Lion OS. Can it be used as a secondary monitor to a PC laptop? If so, how is this accomplished?

    I have the l latest iMac with the Lion OS. Can it be used as a secondary monitor to a PC laptop? If so, how is this accomplished?