text node has text but won't render

Discussion in 'XML' started by Greg, Jun 23, 2006.

  1. Greg

    Greg Guest

    This renders in Firefox perfectly well but the text in the red box remains
    invisible. The program is a subset of a larger and doesn't do much. but
    even after cutting out all the unneccessary stuf, I still can't get it to
    work!!

    Cheers,

    Greg
    ===================
    <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:svg="http://www.w3.org/2000/svg" >
    <xhtml:head>
    <xhtml:title>
    Intermingled XHTML and SVG
    </xhtml:title>
    <xhtml:script type="text/javascript" language="JavaScript"><![CDATA[
    function gogo(evt){
    var targetObj = evt.target; //The object that received the event
    var targetDoc = targetObj.ownerDocument; //Owner document var wg =
    document.getElementById("SVGroot"); var lg =
    document.getElementById("labelz"); //label
    labelBox= targetDoc.createElementNS("http://www.w3.org/2000/svg",
    "svg:rect"); labelBox.setAttributeNS(null, "id", "label1");
    labelBox.setAttributeNS(null, "fill", "red");
    labelBox.setAttributeNS(null, "fill-opacity", 1);
    labelBox.setAttributeNS(null, "x", 700); labelBox.setAttributeNS(null,
    "y", 400); labelBox.setAttributeNS(null, "width", 200);
    labelBox.setAttributeNS(null, "height", 20);
    labelBox.setAttributeNS(null, "visibility", "visible");
    lg.appendChild(labelBox);

    labelText = targetDoc.createElementNS("http://www.w3.org/2000/svg",
    "svg:text"); labelText.setAttributeNS(null, "id", "labelText1");
    labelText.setAttributeNS(null, "x", "5");
    labelText.setAttributeNS(null, "y", "5");
    labelText.setAttributeNS(null, "style", "font-size:16px;
    font-weight:normal; font-family:arial serif; fill:#000000;
    fill-opacity:1; opacity:1"); labelBox.appendChild(labelText);

    textSpan = targetDoc.createElementNS("http://www.w3.org/2000/svg",
    "svg:tspan"); textSpan.setAttributeNS(null, "id", "tspan01");
    textSpan.setAttributeNS(null, "x", "5"); textSpan.setAttributeNS(null,
    "y", "5"); textSpan.setAttributeNS(null, "style", "font-size:16px;
    font-weight:normal; font-family:arial serif; fill:#000000;
    fill-opacity:1; opacity:1"); labelText.appendChild(textSpan);

    lblTxt = targetDoc.createTextNode("this text has just been created");
    textSpan.appendChild(lblTxt);
    document.getElementById("tspan01").firstChild.textContent = "this text
    has just been updated";
    }

    function hh(evt){
    var thisObj = evt.target;
    labelText = thisObj.getAttributeNS(null, "owner");
    document.getElementById("tspan01").firstChild.textContent = labelText;

    }
    ]]></xhtml:script>
    </xhtml:head>
    <xhtml:body >

    <svg:svg width="1024px" height="768px" viewbox="0 0 1024 768"
    onload="gogo(evt);" id="SVG_diag" xmlns:diag="http://www.diag.com/" >
    <svg:g id="SVGroot">

    </svg:g>
    <svg:g id="labelz">

    </svg:g>
    </svg:svg>

    </xhtml:body>
    </xhtml:html>
     
    Greg, Jun 23, 2006
    #1
    1. Advertising

  2. Greg wrote:

    > This renders in Firefox perfectly well but the text in the red box remains
    > invisible. The program is a subset of a larger and doesn't do much.


    You misunderstand the structure of SVG documents, it is rather flat,
    only svg or g elements are container elements of other shapes or text
    but your SVG text element does not belong as a child into the SVG rect
    element.
    So put the SVG text element as a child in an SVG svg element or SVG g
    element.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jun 23, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,468
  2. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,075
    Lau Lei Cheong
    May 15, 2004
  3. Kabeer
    Replies:
    6
    Views:
    3,229
    Thomas Matthews
    Aug 21, 2003
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,438
    Dimitre Novatchev
    Aug 24, 2006
  5. Glenn Gillen
    Replies:
    0
    Views:
    280
    Glenn Gillen
    Nov 17, 2006
Loading...

Share This Page