Modify the XLST DOM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mike

    #1

    Modify the XLST DOM

    I have a stylesheet embedded in my html page like:

    <xml id="xslFix">
    <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:output method="html"/>
    <xsl:param name="statusfie ld"></xsl:param>
    ......<snip>... .
    </xml>

    I want to modify the:
    <xsl:param name="statusfie ld"></xsl:param> node and add a text node
    there so it looks like:
    <xsl:param name="statusfie ld">stuff in here</xsl:param>

    <script language="JavaS cript">
    var sf = new ActiveXObject(" MSXML2.FreeThre adedDOMDocument .4.0");
    sf.load(xslFix) ;
    var omap = sf.documentElem ent.getElements ByTagName('xsl: param');
    for ( var i=0; i<omap.length; i++ )
    {
    if ( omap.item(i).ge tAttribute("nam e") == "statusfiel d" )
    {
    myText=omap.ite m(i).createText Node('stuff..') ;
    omap.item(i).ap pendChild(myTex t);
    }
    }
    </script>

    But this does not work. I get an error message saying something about
    this object not avaailable in this manner.
    Any help is appreciated.

    Mike

  • RobB

    #2
    Re: Modify the XLST DOM

    mike wrote:[color=blue]
    > I have a stylesheet embedded in my html page like:
    >
    > <xml id="xslFix">
    > <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    > version="1.0">
    > <xsl:output method="html"/>
    > <xsl:param name="statusfie ld"></xsl:param>
    > .....<snip>....
    > </xml>
    >
    > I want to modify the:
    > <xsl:param name="statusfie ld"></xsl:param> node and add a text node
    > there so it looks like:
    > <xsl:param name="statusfie ld">stuff in here</xsl:param>
    >
    > <script language="JavaS cript">
    > var sf = new ActiveXObject(" MSXML2.FreeThre adedDOMDocument .4.0");
    > sf.load(xslFix) ;
    > var omap = sf.documentElem ent.getElements ByTagName('xsl: param');
    > for ( var i=0; i<omap.length; i++ )
    > {
    > if ( omap.item(i).ge tAttribute("nam e") == "statusfiel d" )
    > {
    > myText=omap.ite m(i).createText Node('stuff..') ;
    > omap.item(i).ap pendChild(myTex t);
    > }
    > }
    > </script>
    >
    > But this does not work. I get an error message saying something about
    > this object not avaailable in this manner.
    > Any help is appreciated.
    >
    > Mike[/color]

    Believe createTextNode( ) is just a factory method, a member of
    Document. Unlike, say, getElementsByTa gName(), it's not a method of
    other Node objects. Might try...

    myText=document .createTextNode ('stuff..');
    omap.item(i).ap pendChild(myTex t);

    Comment

    Working...