This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Ignore childs


You want to get an element value non-recursively, don't you?

I have tryed it before, too. But I reached a conclusion that it is
impossible without DOM program. (If this conclusion is not right, I also
want to know the way.) What makes it impossible is the element value model
of DOM. If it were not element but attribute, it was easy to achive, though.

Just for reference, here is the element text extraction Javascript function.
If bRecursive variable was reset, this function returns the text of the
element only.

(*((WSH version))*)

  if( oNode.nodeType == 2 / * NODE_ATTRIBUTE * / ) {
    return oNode.nodeValue;
  }

  if( oNode.nodeType == 1 / * NODE_ELEMENT * / ) {
    if( bRecursive ) {
      return oNode.text;
    } else {
      var oChildNodes = oNode.childNodes;
      var sValue = "";
      var oChildNode;
      for( oChildNode = oChildNodes.nextNode(); oChildNode != null;
           oChildNode = oChildNodes.nextNode() ) {
        if( oChildNode.nodeType == 3 / * NODE_TEXT * / ) {
           sValue += oChildNode.nodeValue;
        }
      }
      return sValue;
    }
  }
  return "";

> -----Original Message-----
> From: owner-xsl-list@mulberrytech.com
> [mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Marta Lobato
> Sent: Friday, March 10, 2000 8:52 PM
> To: xsl-list@mulberrytech.com
> Subject: Ignore childs
>
>
> Hello,
>
> I would be so grateful if you could help me.
>
> I have the following XML file:
>
>    <section>
>      <title>This is the title with the acronym
>              <def-acronym>
>                  <acronym>XML</acronym>
>                  <expansion>eXtensible Markup Language</expansion>
>              </def-acronym>
>      </title>
>      <par>Content of the section</par>
>    </section>
>
> And I want this output:
>
>     This is the title with the acronym XML
>
> I am writing the style sheet with
>
>     <xsl:value-of select="title"/>
>
> And I get:
>
> This is the title with the acronym
> XML
> eXtensible Markup Language
>
> I do not want the expansion but I don't want the title in more than one
> lines because this is the parameter for a javascript function and it
> says "unterminated string constant".  I need it in the same line.
>
> Any suggestions?  Thank you.
>
>   Marta Lobato.
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>

--
Shinichiro Hamada(shinchiro.hamada@toshiba.co.jp)
Computer & Network Systems Lab., R&D Center, TOSHIBA, Japan
PN: +81-44-549-2236  Fax: +81-44-520-1841


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]