Insert BASE tag into HTMLDocument problem

Hi,
I've made a prog that read the HTML content from an URL, and write it into a file. But before writing it, I'd like to change the content to add <BASE href="http://www.site.com"></BASE> into the head part of the HTMLDocument. In my prog, I've made a insertBeforeEnd(...) to insert the <BASE> tag, but it's not inserted. I've made another insertBeforeEnd(...) to insert "hello world" (just for test) and it's inserted into the HTMLDocument. Can someone help me ? thanks a lot.
My prog :
import java.io.*;
import java.net.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
public class InsertIntoHTML {
   public static void main(String[] args) {
      URL                  url = null;
      HttpURLConnection      conn;
      HTMLEditorKit         htmlKit;
      HTMLDocument         htmlDoc;
      InputStream            in;
      Element               head;
      boolean               ignoreCharSet = true;
      htmlKit = new HTMLEditorKit();
      htmlDoc = new HTMLDocument();
      try {
         url = new URL("http://www.google.com/");
      catch (java.net.MalformedURLException e) {}
      htmlDoc.putProperty(Document.StreamDescriptionProperty, url);
      htmlDoc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
      // read www.yahoo.com into HTML document
      try {
         conn = (HttpURLConnection) url.openConnection();
         in = conn.getInputStream();
         Reader reader = new InputStreamReader(in);
         Class c = Class.forName("javax.swing.text.html.parser.ParserDelegator");
         HTMLEditorKit.Parser parser = (HTMLEditorKit.Parser) c.newInstance();
         htmlDoc.setParser(parser);
         HTMLEditorKit.ParserCallback htmlReader = htmlDoc.getReader(0);
         parser.parse(reader, htmlReader, ignoreCharSet);
         htmlReader.flush();
      catch (javax.swing.text.BadLocationException ex) {}
      catch (java.lang.ClassNotFoundException e) {}
      catch (java.lang.InstantiationException e) {}
      catch (java.lang.IllegalAccessException e) {}
      catch (java.io.IOException e) {}
      htmlDoc.setBase(url);
      // find <HEAD> tag into HTML document
      head = getHeadElement(htmlDoc);
      try {
         // insert <BASE> tag into <HEAD> element
         htmlDoc.insertBeforeEnd(head, "<BASE href=\"http://www.google.com/\"></BASE>");
         htmlDoc.insertBeforeEnd(head, "Hello world !");
      catch (javax.swing.text.BadLocationException e) {}
      catch (java.io.IOException e) {}
      // write HTML document into file named yahoo.html      
      try {
         htmlKit.write(new FileOutputStream(new File("google.html")), htmlDoc, 0, htmlDoc.getLength());
      catch (java.io.FileNotFoundException e) {}
      catch (java.io.IOException e) {}
      catch (javax.swing.text.BadLocationException e) {}
   // Find first element into HTML document equals to tag parameter
   public synchronized static final Element findElement(Element root, HTML.Tag kind) {
      if(root == null) return(null);
      if(matchElementType(root, kind)) {
         return(root);
      int count = root.getElementCount();
      if(count > 0) {
         for(int i = 0 ; i<count ; i++) {
            Element child = root.getElement(i);
            Element e = findElement(child, kind);
            if(e != null)
               return(e);
   return(null);
   public synchronized static final boolean matchElementType(Element e, HTML.Tag kind) {
      return(e.getAttributes().getAttribute(StyleConstants.NameAttribute) == kind);
   // Find HEAD element into HTML document
   public synchronized static final Element getHeadElement(HTMLDocument doc) {
      return(findElement(doc.getRootElements()[0], HTML.Tag.HEAD));

first, thanks dvorhra09 for your help. unfortunately, if I use &lt; and &gt; instead of '<' and '>', the <BASE> tag is no more interpreted by my browser when the file is loaded, and the <BASE> tag is displayed textually. below, is what I tested :
htmlDoc.insertBeforeEnd(head, "&lt;BASE href=\"http://www.google.com/\"&gt;&lt;/BASE&gt;");

Similar Messages

  • Inserting blockquote tags into a HTMLDocument

    G'Day,
    I'm having a bit of trouble inserting <blockquote> tags into a HTMLDocument.
    Basically I want the blockquote tags to implement an indent feature. ie, you click a button and all the text in the current paragraph gets surrunded by blockquote tags, which when rendered makes it indent.
    The code I'm using is:
    Element current = doc.getParagraphElement(pos);
    try
    doc.insertBeforeStart(current, "<blockquote>");
    doc.insertAfterEnd(current, "</blockquote>");
    catch (Exception e)
    lets say we have html like this:
    <p>
    hello
    </p>
    when this code runs, i get:
    <blockquote>
    </blockquote>
    <p>
    hello
    </p>
    I think that when I do the insertBeforeStart and insert the opening tag, after that completes the document is rendered and the end tag is put in there automatically???
    So, can anyone help me out here and suggest a better way?
    Cheers,
    Leighton.

    I've been trying to get <blockquote> insert working in an editor but it seems to be a quite difficult task even if it's only about inserting a couple of tags into the right slot! This is the closest I got:
    HTMLDocument doc = (HTMLDocument)editor.getDocument();
    int start = editor.getCaretPosition()
    int paraStart = doc.getParagraphElement(start).getStartOffset();
    int paraEnd = doc.getParagraphElement(start).getEndOffset();
    String insideBlockQuotes = doc.getText(paraStart, paraEnd - paraStart);
    doc.setOuterHTML(doc.getParagraphElement(start),"<blockquote><p>"+insideBlockQuotes+"</p></blockquote>");
    This is how it works: Get the current paragraphs start and end positions, read the text between the start and end into a string, replace the paragrapElement with <blockquote><p>..the text from string..</p></blockquote>.
    This works 'in about' but it's far from perfect.. it has the following problems:
    1. It looses all formatting from the quoted paragraph (bold etc. tags from the quoted part)
    2. It assumes that the paragraphElement was a <p> (could have been another element too!)
    3. It's ugly
    Anybody come up with a better way to use blockquote?

  • Insert Encoding tag into xml file. ?xml version="1.0"?

    I am using oracle 10g.
    I am using dbms_xmlgen.getxml function to generate xml data for oracle tables. I use utl_file to write data back into xml file.
    Oracle is generating the file in the following manner...
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <RSLT_ID>1</RSLT_ID>
    </ROW>
    </ROWSET>
    I want to change the following xml header to have encoding information in it as follows...
    <?xml version="1.0" encoding = "AL32UTF8"?>
    How do I achieve that?
    Any suggestions?

    I want to change the following xml header to have encoding informationIn 10g I think you could use a xmlroot hack:
    SQL> select xmlroot(xmlelement(e, dummy), version '1.0" encoding="AL32UTF8') xml from dual
    XML                                                    
    <?xml version="1.0" encoding="AL32UTF8"?>              
    <E>X</E>                                               
    1 row selected.

  • Inserting custom HTML tags into a HTMLDocument to be displayed in a JEditor

    Does anyone know how to insert custom tags into a HTMLDocument to be displayed in a JEditorPane?
    I have tried using the following code,
    kit.insertHTML( doc,
                    jep.getCaretPosition(),
                    "<testtag>FFFF</testtag>",
                    0,
                    0,
                    new HTML.UnknownTag("testtag") );When the above code is run the handleStartTag, handleEndTag and handleText methods are called on the HTMLReader but nothing is inserted into the document model? Can anyone help?
    I have created an instance of HTML.UnknownTag,
      public static HTML.Tag testTag = new HTML.UnknownTag("testtag");I have subclassed HTMLEditorKit and overridden the getParser() method,
      protected Parser getParser(){
        DTD dtd = null;
        try {
          dtd = createDTD( DTD.getDTD("html32"), "html32" );
        } catch ( Exception e ) {
          e.printStackTrace();
        dtd.getElement( "testtag" );
        Parser p = new ParserAdaptor( new DocumentParser( dtd ) );
        return p;
      }I have subclassed HTMLDocument and HTMLDocument.HTMLReader and created a TagAction for my new tag.
    The following code works fine, the custom tag is in the document model,
        String contents =    "<html>"
                           + "<body>"
                           + "<testtag>Here is some text</testtag>"
                           + "</body>"
                           + "</html>";
        ((HTMLDocument)jep.getDocument()).setPreservesUnknownTags(true);
        jep.setText( contents );

    I've been trying to get <blockquote> insert working in an editor but it seems to be a quite difficult task even if it's only about inserting a couple of tags into the right slot! This is the closest I got:
    HTMLDocument doc = (HTMLDocument)editor.getDocument();
    int start = editor.getCaretPosition()
    int paraStart = doc.getParagraphElement(start).getStartOffset();
    int paraEnd = doc.getParagraphElement(start).getEndOffset();
    String insideBlockQuotes = doc.getText(paraStart, paraEnd - paraStart);
    doc.setOuterHTML(doc.getParagraphElement(start),"<blockquote><p>"+insideBlockQuotes+"</p></blockquote>");
    This is how it works: Get the current paragraphs start and end positions, read the text between the start and end into a string, replace the paragrapElement with <blockquote><p>..the text from string..</p></blockquote>.
    This works 'in about' but it's far from perfect.. it has the following problems:
    1. It looses all formatting from the quoted paragraph (bold etc. tags from the quoted part)
    2. It assumes that the paragraphElement was a <p> (could have been another element too!)
    3. It's ugly
    Anybody come up with a better way to use blockquote?

  • Do I need to insert meta tags on domain if it redirects to web.mac page?

    Hi,
    I've set up a domain (http://www.blossomsolutions.ca) with Internic.ca in Canada and filled out a very easy form to redirect to http://web.mac.com/blossomsolutions. Through this excellent forum I learned how to insert meta tags into all my pages on the web.mac site using text edit successfully.
    Now, I'm wondering, will search engines find me if I have "no code" or meta tags at www.blossomsolutions.ca? Internic is only "redirecting" my URL not hosting it. It costs more money if they "host" my domain and I wouldn't have a clue how to set up an index.html page anyway for this domain. Even if I got someone to do this can you redirect an index.html page from blossomsolutions.ca to a web.mac.com page? i.e. does the domain code need to be empty in order for it to redirect?
    Thanks to anyone who can help me with this.
    Dazed and confused,
    Kathleen
    iMAC 2.16GHz 20"   Mac OS X (10.4.10)  
    iMac   Mac OS X (10.4.10)  
    iMac   Mac OS X (10.4.10)  
    iMac   Mac OS X (10.4.10)  

    Hello Kathleen,
    Welcome to the forum. You're site looks very clean and elegant.
    The domain name you purchased (http://www.blossomsolutions.ca/) is serving as a redirecting page to your iWeb generated web page. The answer to whether or not search engines will find you is both yes and no. Search engines use programs called "spiders" that find pages through links and trace out web pages.
    Given some time, sites like Google and MSN will likely find you website (and if you put meta tags in it will display that info in the search engine). But if you are like most iWeb users (myself included) you are impatient for your site to be picked up in search engines. Which is fine, since several search engines provide the means for you to submit your URL. Read this post for more information. http://discussions.apple.com/thread.jspa?messageID=3905977&#3905977
    Looks like you may have already submitted your .mac page.
    Another handy tip for looking up what information a search engine posses on your site is to type "site:" followed by the web address you wish to look up into a search engine. If the search engine has any of the pages to your site it will display them with the meta data they posses. Your site info can be found here. http://www.google.com/search?q=site:http://web.mac.com/blossomsolutions
    I checked your .ca address and google didn't come up with anything.
    Internic.ca should provide you with the means to apply a little bit of a description to your web address. Apart from that, you can't really add any meta data to the domain name.
    Unfortunately even when you get both web addresses picked up by search engines it won't associate them together. They may come up near each other in searches. But the search engine will see them as entirely different sites.
    You could host your site at the domain name if you chose to. The process of publishing is one click like to .mac. But you "Publish to a Folder" and then upload the complete page to the domain name. Its more difficult and cost more (if you chose to retain your .mac account) but it would give you better search engine rankings for your name.
    —"It costs more money if they "host" my domain and I wouldn't have a clue how to set up an index.html page anyway for this domain. Even if I got someone to do this can you redirect an index.html page from blossomsolutions.ca to a web.mac.com page? i.e. does the domain code need to be empty in order for it to redirect?"
    It isn't really worth it have them host your domain name only to put an index.html that redirects to your .mac. Thats basically what the domain forwarding is doing (minus a little bit of info).
    My advice is to keep things how you have them. But, just make sure you get the domain submitted to search engines.
    Hope this wasn't to long or confusing.
    Kind Regards,
    —Eric
    Ash Films
    (see my profile if you want to see my site)

  • Element: Why can't I insert into HTMLDocument?

    I am trying to insert a String into an HTMLDocument. I do not understand why it does not work.
    The followung is my code:
         *  Appends some text in formatted form to a document.
         *  @param text the text to be added
         *  @param doc the HTML document to which to add the text
         *  @return the same document as was passed into the method as an argument,
         *  with new formatted text appended to it
        public Document addStylized(String text, Document doc) {
            StringTokenizer tokenizer = new StringTokenizer(text, "{}", true);
            Style style = contentStyle;
            Element rootElement = doc.getRootElements()[0];
         Element bodyElement = rootElement.getElement(rootElement.getElementIndex(0));
         HTMLDocument htmlDoc = (HTMLDocument) doc;
            while (tokenizer.hasMoreTokens()) {
                String token = tokenizer.nextToken();
                if (token.equals("{")) {
                    token = tokenizer.nextToken();
                    try {
                        htmlDoc.insertBeforeEnd(bodyElement, "<a href=\"" + token +
                                "\">" + token + "</a>");
                    } catch (Exception e) {
                        e.printStackTrace();
                        System.exit(1);
                    tokenizer.nextToken(); // token should be "}" now
                } else {
              try {
                  htmlDoc.insertBeforeEnd(bodyElement, token);
              } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println("token: " + token);
                  System.exit(1);
            return doc;
        }The following is what I get at runtime:
    javax.swing.text.BadLocationException: Invalid insert
            at javax.swing.text.GapContent.insertString(GapContent.java:109)
            at javax.swing.text.DefaultStyledDocument.insert(DefaultStyledDocument.java:187)
            at javax.swing.text.html.HTMLDocument.insert(HTMLDocument.java:230)
            at javax.swing.text.html.HTMLDocument$HTMLReader.flushBuffer(HTMLDocument.java:3185)
            at javax.swing.text.html.HTMLDocument$HTMLReader.flush(HTMLDocument.java:2049)
            at javax.swing.text.html.HTMLDocument.insertHTML(HTMLDocument.java:1143)
            at javax.swing.text.html.HTMLDocument.insertBeforeEnd(HTMLDocument.java:914)
            at quikdic.DICTStylizer.addStylized(DICTStylizer.java:81)
            at quikdic.QuikDicFrame$DefinitionThread.run(QuikDicFrame.java:659)The document passed into the method is an HTMLDocument which has been created with (HTMLDocument) htmlEditorKit.createDefaultDocument();Why am I getting the above error?

    Hi,
    I am not sure if the way you get the BODY tag element is correct in your code. You could use something like the following instead (hd being your HTMLDocument object):
        Element link = findElement(hd.getDefaultRootElement(), HTML.Tag.BODY.toString());
       * find the first occurrence of an <code>Element</code> in the
       * element tree below a given <code>Element</code>
       * @param parent the <code>Element</code> to start looking
       * @param name the name of the <code>Element</code> to search for
       * @return the found <code>Element</code> or null if none is found
      private Element findElement(Element parent, String name) {
        Element foundElement = null;
        Element thisElement = null;
        int count = parent.getElementCount();
        int i = 0;
        while(i < count && foundElement == null) {
          thisElement = parent.getElement(i);
          if(thisElement.getName().equalsIgnoreCase(name)) {
            foundElement = thisElement;
          else {
            foundElement = findElement(thisElement, name);
          i++;
        return foundElement;
      }Hope that helps
    Ulrich

  • Problem inserting a gif into a blob field in a table with sqldev / forms6i

    Problem solved - For those that might be interested, the errors don't make much sense - the problem was with the gif. Seems that these 28 gifs plus the new scans were saved from the scanner with
    GIF - LZW, Transparent color: 255
    Converting them to Black and white allowed them to be loaded.
    If anyone understands why, I'd like to know
    glenn
    I was previously having a problem deleting a row with a blob and it was suggested that I create the table using rowdependencies - which I did as follows.
    CREATE TABLE "MDD"."MDD_FIGURE2"
    (     "FG_FIGURENAME" VARCHAR2(18 BYTE),
         "FG_FIGURE" BLOB,
         CONSTRAINT "FG_FIGURENAME_NN" CHECK ("FG_FIGURENAME" IS NOT NULL) ENABLE
    ) ROWDEPENDENCIES;
    Then I copied my data from my previous table with the following - and everything came across
    INSERT INTO MDD_FIGURE2 (fg_figurename, fg_figure)
    SELECT FIG_FIGNAME, FIG_FIGURE FROM MDD_FIGURE;
    mdd_figure2 was then renamed to mdd_figure
    The table, Mdd_Figure, already contains some 2000+ .gifs that were successfully loaded with Forms 6i (yes, I know it is old, but I am stuck with having to use it). All the .gifs I am loading are from scans and all are less than 64k. However, 28 .gifs would not load. When I insert the .gif into the field and committed the form, the status message tells me a record was written but when I check it, the blob is empty.
    So, when I try to insert one of these problem .gifs in SqlDeveloper, I open the new mdd_figure table, select the blob field, open the edit dialog, set it to figure, select the .gif that I want to load and then save it. The blob field changes from NULL to BLOB, but it is empty. When I try to commit, I get the following error from SqlDev.
    UPDATE "MDD"."MDD_FIGURE" SET WHERE ROWID = 'AAAOeWAAEAAABAlAAz' AND ORA_ROWSCN = '358136842'
    One error saving changes to table "MDD"."MDD_FIGURE":
    Row 14: ORA-01410: invalid ROWID
    I use rollback to restore the record to it's previous state.
    If I load one of the successfully loaded .gifs into the same field, it loads perfectly as follows.
    UPDATE "MDD"."MDD_FIGURE" SET WHERE ROWID = 'AAAOeWAAEAAABAoAAp' AND ORA_ROWSCN = '358136522'
    Commit Successful
    It appears the 28 gifs have a problem. I've re-scanned them, with the same results. They are just small scanned line map images from our earlier publications. They view properly in several different graphics programs and I can't find anything wrong with them.
    I notice that the ROWID's are different while the ORA_ROWSCN's are the same - but what is the significance of that?
    Any suggestions as to what is happening and what I can do about it?
    Thanks for any help you can give me.
    glenn
    (Database is 10R2 and sqldev is the most recent one)
    Edited by: gconley on Sep 25, 2008 9:51 PM

    solved it myself - problem was with the gif

  • Problem with inserting two BLOBs into a table using setBinaryStream

    DBMS 9.2.0.1.0, Oracle JDBC driver 10.1.0.2.0
    The following code insert in one INSERT two BLOBs
    into two columns using PreparedStatement.setBinaryStream(). When the size of the of at least one blob exceeds
    some limit (? 2k, 4k ?), the values are swapped and
    inserted into wrong columns.
    Please, is this a problem in JDBC driver?
    ====================================================
    import java.io.ByteArrayInputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.sql.Statement;
    * Test - two BLOBs swapped problem.
    * If size of the blob is larger that some treshold, they are swapped in the database.
    public class BlobSwapTest {
    private static Connection getConnection() throws SQLException {
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    } catch (ClassNotFoundException cnfe) {
    throw new SQLException("ClassNotFoundException: " + cnfe.getMessage());
    return DriverManager.getConnection("jdbc:oracle:thin:@//HOST:1521/DB", "USER", "PSWD");
    private static void createTable() throws SQLException {
    Connection conn = getConnection();
    Statement stmt = null;
    try {
    stmt = conn.createStatement();
    try {
    stmt.execute("DROP TABLE BlobTest2");
    } catch (SQLException e) {
    System.err.println("Table BlobTest2 was not deleted: " + e.getMessage());
    stmt.execute(
    "CREATE TABLE BlobTest2 ("
    + " pk VARCHAR(512), "
    + " blob BLOB, "
    + " blobB BLOB, "
    + " PRIMARY KEY (pk)"
    + ")"
    } finally {
    try {
    if (stmt != null) stmt.close();
    } finally {
    conn.close();
    public static void main(String[] args) throws SQLException {
    createTable();
    Connection conn = getConnection();
    PreparedStatement pstmt = null;
    try {
    conn.setAutoCommit(false);
    pstmt = conn.prepareStatement("INSERT INTO BlobTest2 VALUES (?,?,?)");
    final int size = 5000; // change the value to 500 and the test is OK
    byte[] buf = new byte[size];
    byte[] buf2 = new byte[size];
    for (int i = 0; i < size; i++) {
    buf = 66;
    buf2 = 88;
    pstmt.setString(1, "PK value");
    pstmt.setBinaryStream(2, new ByteArrayInputStream(buf), size);
    pstmt.setBinaryStream(3, new ByteArrayInputStream(buf2), size);
    pstmt.executeUpdate();
    conn.commit();
    } finally {
    if (pstmt != null) pstmt.close();
    conn.close();
    ====================================================

    See my response in the JVM forum.

  • Urgent - pls help - Problem while inserting binary file into Oracle DB

    Hi,
    I am trying to insert binary files into a Blob column in a Oracle 10G table.
    The binary files would be uploaded by the web users and hence come as multipart request. I use apache commons upload streaming API to handle it. Finally i am getting a input stream of the uploaded file.
    The JDBC code is
    PreparedStatement ps=conn.prepareStatement("insert into bincontent_table values(?)");
    ps.setBinaryStream(1,inStream,length);
    My problem starts when i try to find the length of the stream. available() method of inputstream does not return the full length of the stream. so i put a loop to read thru the stream and find the length as shown below
    int length=0;
    while((v=inStream.read())!=-1)
    length++;
    Now, though i got the length, my stream pointer has reached the end and i cant reset it(it throws an error if i try).
    So i copied the stream content to a byte array and created an ByteArrayInputStream like this.
    tempByteArray=new byte[length];
    stream.read(tempByteArray,0,length);
    ByteArrayInputStream bais=new ByteArrayInputStream(tempByteArray);
    Now if i pass this bytearray input stream instead of the normal input stream to the prepared statement's setBinaryStream() method it throws an error as
    "ORA-01460: unimplemented or unreasonable conversion requested".
    Now how to solve this?
    My doubts are ,
    1) preparedStatement.setBinaryStream(int parameterIndex, InputStream x, int length) expects an inputstream and its length. if i have the stream how to find its length with out reading the stream?
    2) Also as the length parameter is a integer, what if i have a large binary file whose length runs more than the capacity of integer
    3) Alternatively there is a setBlob(int i, Blob x) in prepared statement. But how to instantiate a Blob object and set it here
    4) Is there any better way to do this.
    Thanks in advance

    "ORA-01460: unimplemented or unreasonable conversion
    requested".When the setBinaryStream method is used, the driver may have to do extra work to determine whether the parameter data should be sent to the server as a LONGVARBINARY or a BLOB (reference: javadoc)
    1) preparedStatement.setBinaryStream(int parameterIndex,
    InputStream x, int length) expects an inputstream and its length. if i
    have the stream how to find its length with out reading the stream?no. stream may have no specified length. i think you have wrong understanding about stream.
    2) Also as the length parameter is a integer, what if i have a large
    binary file whose length runs more than the capacity of integer
    3) Alternatively there is a setBlob(int i, Blob x) in prepared statement.
    But how to instantiate a Blob object and set it here
    4) Is there any better way to do this.use ps.setBlob(1, instream) instead

  • Any one having problems inserting Pages files into iBook author"

    Ever since I updated the Pages a week ago, iBook Author is unable to read Pages files while attempting to insert. Never had a problem in previous versions of Pages or files created a few months ago. The only work around is to copy text and past into new sections in iBook Author. Tedious. Any solution appreciated.

    Aerosolman wrote:
    I found a work around. Exported to Word from Pages 5.0.1 then inserted into IBA.
    Very useful info!
    I ran some tests with a new Pages 5 doc saved in both Pages 5 format and exported to Pages 09 format, and iBA had no problem importing them.  So perhaps the problem is confined to older docs.

  • Insert element into array problem

    Hi,
    I have problem about how to insert value into an array. here is one section, could anyone help me to insert input value into array and delete the first value in the array. Gap means to fill in code
    void Ins(String name)
    // Insert name or increment its multiplicity.
    // If the bag is full remove the oldest entry.
    int i; // Running index on BagName
    int target; // if target < n then name.equals(BagName[target]);
    // else target == n
    Date EntryDate; // Current date and time
    // Get current date and time
    EntryDate = new Date();
    BagDate[n] = EntryDate.toString();
    Mult[n] = n+1;
    BagName[n] = name;
    n++;
    // Search bag for name
    // Gap 2
    // Assertion: target < n => name.equals(BagName[target])
    // else target == n
    // Update Mult if target < n
    // Gap 3
    // Make room for and insert name if target not found
    } // Ins(String name)
    Message was edited by:
    sibojava
    Message was edited by:
    sibojava

    Do you have several accounts?
    See this thread, it's the same question:
    http://forum.java.sun.com/thread.jspa?threadID=5143232
    Kaj

  • Problem - insert JSON string into table in CLR function

    Hi
    I create a CLR function to insert JSON string into table.
    With this line 
    mt = JsonConvert.DeserializeObject<MyTable>(jsonStr.ToString());
    The class is OK (no error), but when I try to add the Assembly in Microsoft SQL Server Management Studio, it has error :
    Assembly 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed.' was not found in the SQL catalog.
    (I have Newtonsoft.Json in the Reference)
    Please help !
    Thanks

    Hi Bob
    Could you elaborate a bit more?
    I think the code is ok. The problem is when I deploy the Visual Studio creates/alters the assembly, and get the error
    Error:  SQL72014: .Net SqlClient Data Provider: Msg 6503, Level 16, State 12, Line 1 Assembly 'newtonsoft.json, version=6.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed.' was not found in the SQL catalog.
    ALTER ASSEMBLY [Database1]
        FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C0103000DE411540000000000000000E00002210B010B000012000000060000000000008E3000000020000000400000000000100020000000020000040000000000000006000000000000000080000000020000000000000300608500001000001000000000100000100000000000001000000000000000000000003C3000004F00000000400000A802000000000000000000000000000000000000006000000C000000042F00001C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E7465787400000094100000002000000012000000020000000000000000000000000000200000602E72737263000000A8020000004000000004000000140000000000000000000000000000400000402E72656C6F6300000C0000000060000000020000001800000000000000000000000000004
    An error occurred while the batch was being executed.
    Done building project "Database1.sqlproj" -- FAILED.
    This is my FillRow function. Without the bold line, the everything is fine. I can create the assembly, then create the SQL function. Done. When I call select from the SQL function, it returns 10 rows as expected.
    public static IEnumerable getTable(SqlString jsonStr)
            ArrayList resultCollection = new ArrayList();
            MyTable mt;
            //mt = JsonConvert.DeserializeObject<MyTable>(jsonStr.ToString());
            int c = 1;
            while (c < 10)
                mt = new MyTable();
                mt.GlobalId = c.ToString();
                mt.DateSet = "DS=!=" + c.ToString();
                mt.Timestamp = "TS==" + c.ToString();
                mt.PartnerId = "PI==" + c.ToString();
                mt.PartnerUserId = "PUI=" + c.ToString();
                mt.UserIP = "UIP=" + c.ToString();
                mt.UserAgent = "UG=" + c.ToString();
                mt.Referer = "R=" + c.ToString();
                resultCollection.Add(mt);
                c++;
            //resultCollection.Add(mt);
            return resultCollection;

  • Insert HTML Page into XML CDATA Tag

    Hi Guy
    I have a very big problem.
    I create a little web site and I use XSL + XML to produce output.Now I
    want to add a part of html page into xml tag to use a custom page section.
    But i find a problme,
    see the example :
    I use this xml :
    <resources>
    <html><![CDATA[<B>Hello World</B>]]></html>
    </resources>
    trasform xml with xsl page
    and my output into html browser is (&lt);B(&gt);Hello World(&lt);/B(&gt);(please remove the bracket( ) while reading the text to understand my problem)
    my BOLD html tag is not parse by browser because xslt parser trasform
    my special tag into other tag.
    I want output like this:
    <b>Hello World</b>
    But it's coming like (&lt);B(&gt);Hello World(&lt);/B(&gt); (please remove the bracket( ) while reading the text to understand my problem)
    Can you help me ?
    this is my trasformation function :
    private Transformer getXSLTransformer (xslFile) throws
    XSLTransformerConfigurationException {
    try {
    Transformer transformer = null;
    tFactory = TransformerFactory.newInstance();
    transformer = tFactory.newTransformer(new
    StreamSource(xslFile)); // load xslFile from disk
    } catch (TransformerConfigurationException tce) {
    throw new XSLTransformerConfigurationException(tce.getMessage());
    return transformer;
    public String myTrasform(String xml,String xslFile) throws Exception {
    StringWriter outputString = new StringWriter(512);
    Transformer transformer = getXSLTransformer (xslFile);
    transformer.transform(new StreamSource(new StringReader(xml)), new
    StreamResult(outputString));
    return outputString.toString();
    Thank's in advance.
    kuruvi
    Edited by: Mc_Kuruvi on Jun 14, 2009 3:47 AM

    Read:
    Oracle® XML DB
    Developer's Guide
    10g Release 1 (10.1)
    Part No. B10790-01
    December 2003
    1. "Do I use sqlloader and what datatype?"
    Use XMLType
    2. "I have embedded graphics so do the images get stored separately or does the entire page get stored as a BLOB datatype?"
    Page 827:
    The Oracle XML DB native datatype XMLType helps store and manipulate XML. Multiple storage options (Character Large Object (CLOB) or structured XML) are available with XMLType, and administrators can choose a storage that meets their requirements. CLOB storage is an un-decomposed storage that is like an image of the original XML.

  • Insert multiple rows into dB from one dynamic HTML form problem

    Hi,
    - I have form which has dynamically generated text fields so I don't want to hard code the field names into the servlet
    - A user will fill in one or more of the text boxes with a number and submit to the servlet (the name of the field represents an item ID, the value represents a quantity the user wants of that item).
    - The servlet needs to insert a new record into a table for each field that is not null.
    My question is how!
    If I send as an array or string, how will the servlet know that each submitted field needs to be inserted as a new record as opposed to one long record?
    I know I'll need to use a loop of somekind; how will I know how long to loop for if the number of 'not null' fields is not static? I need to get a value for the number of 'not null' fields from the form before the loop starts I think but don't know how...
    Also, should I call an SQL procedure that has an insert-loop OR should I have the servlet loop a call to a single insert statement? (am I making sense!?)
    Anyway, I've seen many examples where a submitted form updates/inserts one record into a table but never any for multiple records at one time. I'm using a Tomcat/Oracle set up, and I'm "New to Java"...
    Many thanks in advance.

    sorry, but I dont' understand very well what do you want to do!
    In any case if you want to retrieve all parameters (and you don't know what they are), you can use a general cosde like this:
    Enumeration names= request.getParameterNames();
    while(names.hasMoreElements()) {
    // in 'name' you store the name of the parameter
    String name = (String) names.nextElement();
    // in 'value' you store it's value
    String value = request.getParameter(name);
    remember that ALL parameter values can't be null (if they are void their value is "").
    The only case that you can get a null value is when you try to access a non existing parameter (like request.getParameter("pwqjsak"));
    I hope this helps! Else try to give me more info about your problem

  • How to change inner content of HTML tag using HTMLDocument?

    I want to change the inner content of an HTML tag from a HTMLDocument. The tag is like
    <span id ="id1">Replace me</span>.
    So I want to change the text "Replace me" inside the span tag and replace it with an other text.
    I can get the span element using
    HTMLDocument.getElement("id1")
    I have tried many things with the Element instance i got from getElement. But I find no way to change the inner content of the HTML element. Any ideas?

    If I use JDK 1.5 the SPAN tag works, so I checked the core of the problem which is inserting HTML code in an HTML tag.
    setInnerHTML works fine for block tags like DIV but not if the tag is a leaf element like the SPAN tag. I have tried to use the following code for leaf elements:
    Element elem = m_htmlDocument.getElement(id);
    int nStartOffest = elem.getStartOffset();
    int nEndOffset = elem.getEndOffset();
    int nLength = nEndOffset - nStartOffest;
    m_htmlDocument.replace(nStartOffest, nLength, html, elem.getAttributes());
    This works, but only if the new HTML string does not contain HTML tags like a link <href..... >. If the string contains HTML tags the replace method masks all characters like < or >. So the link is not shown as link in the HTML page but as HTML text.
    The next thing I have tried is using
    m_htmlDocument.setOuterHTML(elem, html);
    This works too but it replaces the whole original HTML element like the SPAN tag.
    So there is still the question how to insert HTML text into a leaf Element in a HTMLDocument.

Maybe you are looking for

  • Can't create or modify ldap group or user

    I have a web proxy 4.0.6 (ans i try with 4.0.7)server link with 2003 active directory server But I cannot create or manage group The BaseDN is OU=company,DC=ssc,DC=com The BindDN is CN=Administrator,CN=Users,DC=ssc,DC=com The web proxy server can add

  • How to set adapter specific message attributes on Pi 7.1 inside a Java map.

    Hello, how can I set adapter specific message attributes in a Java mapping on PI 7.1.? The TransformationInput grants access to the DynamicConfiguration but the TransformationOutput doesn't. I have found threads refering to the old way of implementin

  • Register with shared services - failed

    I am trying to install EPM 11.1.1.2 and I get this error for the point "register with shared services" for every item except Essbase. Shared Services is running, I can connect to the Web App on localhost:28080/interop and manage users and groups but

  • HT1766 iphone64.msi

    Hi I am getting below error : iphone64.msi not found when i try to install iTunes. I really appericiate any help or suggestion. thanks, Cholate

  • SAPMMC All Settings Gone after running CCCleaner , How to get all settings

    Hello All SAPMMC All Settings Gone after running CCCleaner , How to get all settings back . I donot know what is SID ( System ID ), Instance etc. If this is not relevant to this forum plz let me know which forum .... Regards Rohit