Results 1 to 2 of 2
  1. #1
    Floxxx is offline Member
    Join Date
    Dec 2009
    Posts
    1
    Rep Power
    0

    Default Parsing & handling of <object> and <param> tags

    Hi all,

    I'm working on allowing people to paste certain embedded video code into a wysiwyg / html editor we've built with the help of (amongst others) javax.swing.text.html.HTMLWriter.

    I'm facing the following problem here:

    When i try to parse the <object><param></param></object> piece, it removes the <param> tags, and incorporates these in the <object> tag. For example:

    XML Code:
    <object width="300" height="250"><param name="allowscriptaccess" value="always"></param></object>
    becomes:

    XML Code:
    <object width="300" height="250" allowScriptAccess="always"></object>
    All param tags get converted into the object tag as String attributes. Problem with this is that the allowScriptAccess attribute is not a valid attribute of the object tag.

    Is there any way to prevent this conversion so it will retain the <param> tags?

    Thank you in advance.

  2. #2
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    Everything you need is at least implicit in javax/swing/text/html/HTMLDocument.java

    Curiously, its documentation says the PARAM tags are handled by HiddenAction,
    but the code actually has them handled by ObjectAction:
    Java Code:
    tagMap.put(HTML.Tag.PARAM, new ObjectAction());
    and ObjectAction does indeed stuff the PARAM values as attributes of the surrounding OBJECT.

    The HTMLDocument code suggests subclassing HTMLReader:
    To change the structure one
    can subclass <code>HTMLReader</code>, and reimplement the method
    getReader(int) to return the new reader implementation.
    Unfortunately I haven't time today to try this, but it should be straight forward.
    I think the subclass just needs to have a constructor like:

    Java Code:
    public MyHTMLReader (int offset) {
            super(offset, 0, 0, null);
            tagMap.put(HTML.Tag.PARAM, new HiddenAction());
    }
    or maybe some newly devised TagAction instead of HiddenAction.

Similar Threads

  1. parsing Object to XML
    By kievari in forum New To Java
    Replies: 12
    Last Post: 11-25-2009, 12:34 PM
  2. Javadoc - cannot compile @param tags
    By jon80 in forum New To Java
    Replies: 9
    Last Post: 05-14-2009, 09:57 AM
  3. Replies: 1
    Last Post: 07-22-2008, 05:27 PM
  4. jsp:param action
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-24-2007, 11:03 AM
  5. Creating Document object for XML parsing
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-19-2007, 05:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •