зеркало из https://github.com/mozilla/gecko-dev.git
fix for 77889; item(k) -> getNextSibling; r/a=peterv, sr=jst
This commit is contained in:
Родитель
2f3b8a65aa
Коммит
dca920a1ff
|
@ -21,13 +21,13 @@
|
|||
* Keith Visco
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: XMLDOMUtils.cpp,v 1.12 2001/04/03 12:37:44 peterv%netscape.com Exp $
|
||||
* $Id: XMLDOMUtils.cpp,v 1.13 2001/05/14 14:22:41 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* XMLDOMUtils
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.12 $ $Date: 2001/04/03 12:37:44 $
|
||||
* @version $Revision: 1.13 $ $Date: 2001/05/14 14:22:41 $
|
||||
**/
|
||||
|
||||
#include "XMLDOMUtils.h"
|
||||
|
@ -44,7 +44,7 @@ Node* XMLDOMUtils::copyNode(Node* node, Document* owner, NamespaceResolver* reso
|
|||
|
||||
//-- make sure owner exists if we are copying nodes other than
|
||||
//-- document nodes
|
||||
if ((nodeType != Node::DOCUMENT_NODE) && (!owner)) return 0;
|
||||
if (nodeType != Node::DOCUMENT_NODE && !owner) return 0;
|
||||
Node* newNode = 0;
|
||||
UInt32 i = 0;
|
||||
switch ( nodeType ) {
|
||||
|
@ -76,9 +76,10 @@ Node* XMLDOMUtils::copyNode(Node* node, Document* owner, NamespaceResolver* reso
|
|||
case Node::DOCUMENT_FRAGMENT_NODE :
|
||||
{
|
||||
newNode = owner->createDocumentFragment();
|
||||
NodeList* nl = node->getChildNodes();
|
||||
for (i = 0; i < nl->getLength(); i++) {
|
||||
newNode->appendChild(copyNode(nl->item(i), owner, resolver));
|
||||
Node* tmpNode = node->getFirstChild();
|
||||
while (tmpNode) {
|
||||
newNode->appendChild(copyNode(tmpNode, owner, resolver));
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -108,9 +109,10 @@ Node* XMLDOMUtils::copyNode(Node* node, Document* owner, NamespaceResolver* reso
|
|||
}
|
||||
}
|
||||
//-- copy children
|
||||
NodeList* nl = element->getChildNodes();
|
||||
for (i = 0; i < nl->getLength(); i++) {
|
||||
newElement->appendChild(copyNode(nl->item(i), owner, resolver));
|
||||
Node* tmpNode = element->getFirstChild();
|
||||
while (tmpNode) {
|
||||
newElement->appendChild(copyNode(tmpNode, owner, resolver));
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
newNode = newElement;
|
||||
break;
|
||||
|
@ -143,7 +145,6 @@ void XMLDOMUtils::getNodeValue(Node* node, String* target) {
|
|||
|
||||
int nodeType = node->getNodeType();
|
||||
Element* element = 0;
|
||||
NodeList* nl = 0;
|
||||
|
||||
switch ( nodeType ) {
|
||||
case Node::ATTRIBUTE_NODE :
|
||||
|
@ -155,15 +156,15 @@ void XMLDOMUtils::getNodeValue(Node* node, String* target) {
|
|||
case Node::DOCUMENT_FRAGMENT_NODE :
|
||||
case Node::ELEMENT_NODE :
|
||||
{
|
||||
nl = node->getChildNodes();
|
||||
for (UInt32 i = 0; i < nl->getLength(); i++) {
|
||||
nodeType = nl->item(i)->getNodeType();
|
||||
if ((nodeType == Node::TEXT_NODE) ||
|
||||
(nodeType == Node::ELEMENT_NODE) ||
|
||||
(nodeType == Node::CDATA_SECTION_NODE))
|
||||
{
|
||||
getNodeValue(nl->item(i),target);
|
||||
}
|
||||
Node* tmpNode = node->getFirstChild();
|
||||
while (tmpNode) {
|
||||
nodeType = tmpNode->getNodeType();
|
||||
if (nodeType == Node::TEXT_NODE ||
|
||||
nodeType == Node::ELEMENT_NODE ||
|
||||
nodeType == Node::CDATA_SECTION_NODE) {
|
||||
getNodeValue(tmpNode,target);
|
||||
};
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
|
@ -63,21 +63,19 @@ MBool Attr::getSpecified() const
|
|||
//
|
||||
const String& Attr::getValue()
|
||||
{
|
||||
Int32 valueLoop;
|
||||
nodeValue = NULL_STRING;
|
||||
NodeList* childList = getChildNodes();
|
||||
Int32 numChildren = childList->getLength();
|
||||
|
||||
for (valueLoop=0;valueLoop<numChildren;valueLoop++)
|
||||
{
|
||||
if (childList->item(valueLoop)->getNodeType() != Node::ENTITY_REFERENCE_NODE)
|
||||
{
|
||||
nodeValue.append(childList->item(valueLoop)->getNodeValue());
|
||||
if (valueLoop < (numChildren-1))
|
||||
Node* child = getFirstChild();
|
||||
while (child) {
|
||||
if (child->getNodeType() != Node::ENTITY_REFERENCE_NODE) {
|
||||
nodeValue.append(child->getNodeValue());
|
||||
child = child->getNextSibling();
|
||||
if (child)
|
||||
nodeValue.append(",");
|
||||
} else {
|
||||
child = child->getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
return nodeValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*
|
||||
* Michel Casabianca, casa@sdv.fr
|
||||
* -- added additional empty elements to the HTML tag list
|
||||
* $Id: HTMLPrinter.cpp,v 1.5 2001/04/08 14:37:24 peterv%netscape.com Exp $
|
||||
* $Id: HTMLPrinter.cpp,v 1.6 2001/05/14 14:22:44 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
#include "printers.h"
|
||||
|
@ -34,7 +34,7 @@
|
|||
* A class for printing XML nodes.
|
||||
* This class was ported from XSL:P Java source
|
||||
* @author <a href="kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.5 $ $Date: 2001/04/08 14:37:24 $
|
||||
* @version $Revision: 1.6 $ $Date: 2001/05/14 14:22:44 $
|
||||
**/
|
||||
//---------------/
|
||||
//- Contructors -/
|
||||
|
@ -120,8 +120,6 @@ MBool HTMLPrinter::print(Node* node, String& currentIndent) {
|
|||
|
||||
//-- if (node == null) return false;
|
||||
|
||||
NodeList* nl;
|
||||
|
||||
switch(node->getNodeType()) {
|
||||
|
||||
//-- print Document Node
|
||||
|
@ -131,9 +129,10 @@ MBool HTMLPrinter::print(Node* node, String& currentIndent) {
|
|||
out <<endl<< " \"http://www.w3.org/TR/REC-html40/loose.dtd\">" <<endl;
|
||||
Document* doc = (Document*)node;
|
||||
//-- printDoctype(doc.getDoctype());
|
||||
nl = doc->getChildNodes();
|
||||
for (int i = 0; i < nl->getLength(); i++) {
|
||||
print(nl->item(i),currentIndent);
|
||||
Node* tmpNode = doc->getFirstChild();
|
||||
while (tmpNode) {
|
||||
print(tmpNode,currentIndent);
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -166,27 +165,25 @@ MBool HTMLPrinter::print(Node* node, String& currentIndent) {
|
|||
}
|
||||
}
|
||||
out << R_ANGLE_BRACKET;
|
||||
NodeList* nl = element->getChildNodes();
|
||||
Node* child = element->getFirstChild();
|
||||
if (useFormat) out<<endl;
|
||||
for (i = 0; i < nl->getLength(); i++) {
|
||||
Node* child = nl->item(i);
|
||||
while (child) {
|
||||
switch(child->getNodeType()) {
|
||||
case Node::COMMENT_NODE:
|
||||
{
|
||||
case Node::COMMENT_NODE: {
|
||||
out << COMMENT_START;
|
||||
out << ((CharacterData*)child)->getData();
|
||||
out << COMMENT_END;
|
||||
break;
|
||||
}
|
||||
case Node::TEXT_NODE:
|
||||
case Node::CDATA_SECTION_NODE:
|
||||
{
|
||||
case Node::CDATA_SECTION_NODE: {
|
||||
out << ((Text*)child)->getData();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
child = child->getNextSibling();
|
||||
}
|
||||
out << flush;
|
||||
if (useFormat) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* Bob Miller, kbob@oblix.com
|
||||
* -- plugged core leak.
|
||||
*
|
||||
* $Id: XMLPrinter.cpp,v 1.7 2000/09/07 03:40:24 kvisco%ziplink.net Exp $
|
||||
* $Id: XMLPrinter.cpp,v 1.8 2001/05/14 14:22:45 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
#include "printers.h"
|
||||
|
@ -36,7 +36,7 @@
|
|||
* A class for printing XML nodes.
|
||||
* This class was ported from XSL:P Java source
|
||||
* @author <a href="kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.7 $ $Date: 2000/09/07 03:40:24 $
|
||||
* @version $Revision: 1.8 $ $Date: 2001/05/14 14:22:45 $
|
||||
**/
|
||||
|
||||
/**
|
||||
|
@ -194,8 +194,6 @@ MBool XMLPrinter::print(Node* node, String& currentIndent) {
|
|||
|
||||
//-- if (node == null) return false;
|
||||
|
||||
NodeList* nl;
|
||||
|
||||
switch(node->getNodeType()) {
|
||||
|
||||
//-- print Document Node
|
||||
|
@ -206,9 +204,10 @@ MBool XMLPrinter::print(Node* node, String& currentIndent) {
|
|||
out << version;
|
||||
out << DOUBLE_QUOTE << PI_END << endl;
|
||||
//-- printDoctype(doc.getDoctype());
|
||||
nl = doc->getChildNodes();
|
||||
for (int i = 0; i < nl->getLength(); i++) {
|
||||
print(nl->item(i),currentIndent);
|
||||
Node *node = doc->getFirstChild();
|
||||
while (node) {
|
||||
print(node,currentIndent);
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -250,9 +249,8 @@ MBool XMLPrinter::print(Node* node, String& currentIndent) {
|
|||
}
|
||||
}
|
||||
|
||||
NodeList* childList = element->getChildNodes();
|
||||
int size = childList->getLength();
|
||||
if ((size == 0) && (useEmptyElementShorthand))
|
||||
Node* child = element->getFirstChild();
|
||||
if (!child && (useEmptyElementShorthand))
|
||||
{
|
||||
out << FORWARD_SLASH << R_ANGLE_BRACKET;
|
||||
if (useFormat) {
|
||||
|
@ -264,35 +262,35 @@ MBool XMLPrinter::print(Node* node, String& currentIndent) {
|
|||
// Either children, or no shorthand
|
||||
MBool newLine = MB_FALSE;
|
||||
out << R_ANGLE_BRACKET;
|
||||
if ((useFormat) && (size > 0)) {
|
||||
if (useFormat && child) {
|
||||
// Fix formatting of PCDATA elements by Peter Marks and
|
||||
// David King Lassman
|
||||
// -- add if statement to check for text node before
|
||||
// adding line break
|
||||
if (childList->item(0)->getNodeType() != Node::TEXT_NODE) {
|
||||
if (child->getNodeType() != Node::TEXT_NODE) {
|
||||
out << endl;
|
||||
newLine = MB_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Node* child = 0;
|
||||
String newIndent(indent);
|
||||
newIndent.append(currentIndent);
|
||||
for (int i = 0; i < size; i++) {
|
||||
child = childList->item(i);
|
||||
if ((useFormat) && newLine)
|
||||
{
|
||||
Node *lastChild = child;
|
||||
while (child) {
|
||||
if (useFormat && newLine) {
|
||||
out << newIndent;
|
||||
}
|
||||
newLine = print(child,newIndent);
|
||||
lastChild = child;
|
||||
child = child->getNextSibling();
|
||||
}
|
||||
if (useFormat) {
|
||||
// Fix formatting of PCDATA elements by Peter Marks and
|
||||
// David King Lassman
|
||||
// -- add if statement to check for text node before
|
||||
// adding line break
|
||||
if (child) {
|
||||
if (child->getNodeType() != Node::TEXT_NODE) {
|
||||
if (lastChild) {
|
||||
if (lastChild->getNodeType() != Node::TEXT_NODE) {
|
||||
out << currentIndent;
|
||||
}
|
||||
}
|
||||
|
@ -302,8 +300,8 @@ MBool XMLPrinter::print(Node* node, String& currentIndent) {
|
|||
out << R_ANGLE_BRACKET;
|
||||
if (useFormat) {
|
||||
Node* sibling = node->getNextSibling();
|
||||
if ((!sibling) ||
|
||||
(sibling->getNodeType() != Node::TEXT_NODE))
|
||||
if (!sibling ||
|
||||
sibling->getNodeType() != Node::TEXT_NODE)
|
||||
{
|
||||
out<<endl;
|
||||
return MB_TRUE;
|
||||
|
@ -479,7 +477,7 @@ void XMLPrinter::printComment(const String& data) {
|
|||
for (int i = 0; i < data.length(); i++) {
|
||||
currChar = data.charAt(i);
|
||||
|
||||
if ((currChar == DASH) && (prevChar == DASH))
|
||||
if (currChar == DASH && prevChar == DASH)
|
||||
*ostreamPtr << SPACE << DASH;
|
||||
else
|
||||
printUTF8Char(currChar);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
|
@ -21,14 +21,14 @@
|
|||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: BasicNodeExpr.cpp,v 1.3 2001/04/11 15:00:57 axel%pike.org Exp $
|
||||
* $Id: BasicNodeExpr.cpp,v 1.4 2001/05/14 14:22:46 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
#include "Expr.h"
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.3 $ $Date: 2001/04/11 15:00:57 $
|
||||
* @version $Revision: 1.4 $ $Date: 2001/05/14 14:22:46 $
|
||||
**/
|
||||
|
||||
//- Constructors -/
|
||||
|
@ -66,10 +66,11 @@ BasicNodeExpr::~BasicNodeExpr() {};
|
|||
ExprResult* BasicNodeExpr::evaluate(Node* context, ContextState* cs) {
|
||||
NodeSet* nodeSet = new NodeSet();
|
||||
if ( !context ) return nodeSet;
|
||||
NodeList* nl = context->getChildNodes();
|
||||
for (UInt32 i = 0; i < nl->getLength(); i++ ) {
|
||||
Node* node = nl->item(i);
|
||||
if (matches(node, context, cs)) nodeSet->add(node);
|
||||
Node* node = context->getFirstChild();
|
||||
while (node) {
|
||||
if (matches(node, context, cs))
|
||||
nodeSet->add(node);
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
return nodeSet;
|
||||
} //-- evaluate
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
|
@ -21,7 +21,7 @@
|
|||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: ElementExpr.cpp,v 1.5 2001/04/08 14:37:18 peterv%netscape.com Exp $
|
||||
* $Id: ElementExpr.cpp,v 1.6 2001/05/14 14:22:46 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
#include "Expr.h"
|
||||
|
@ -68,11 +68,11 @@ ExprResult* ElementExpr::evaluate(Node* context, ContextState* cs) {
|
|||
|
||||
if ( !context ) return nodeSet;
|
||||
|
||||
NodeList* nl = context->getChildNodes();
|
||||
|
||||
for (UInt32 i = 0; i < nl->getLength(); i++ ) {
|
||||
Node* node = nl->item(i);
|
||||
if (matches(node, context, cs)) nodeSet->add(node);
|
||||
Node* node = context->getFirstChild();
|
||||
while (node) {
|
||||
if (matches(node, context, cs))
|
||||
nodeSet->add(node);
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
return nodeSet;
|
||||
} //-- evaluate
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
|
@ -21,12 +21,12 @@
|
|||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: LocationStep.cpp,v 1.5 2001/04/11 15:00:58 axel%pike.org Exp $
|
||||
* $Id: LocationStep.cpp,v 1.6 2001/05/14 14:22:47 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
Implementation of an XPath LocationStep
|
||||
@version $Revision: 1.5 $ $Date: 2001/04/11 15:00:58 $
|
||||
@version $Revision: 1.6 $ $Date: 2001/05/14 14:22:47 $
|
||||
*/
|
||||
|
||||
#include "Expr.h"
|
||||
|
@ -211,10 +211,11 @@ ExprResult* LocationStep::evaluate(Node* context, ContextState* cs) {
|
|||
break;
|
||||
default: //-- Children Axis
|
||||
{
|
||||
NodeList* nl = context->getChildNodes();
|
||||
for ( UInt32 i = 0; i < nl->getLength(); i++ ) {
|
||||
if ( nodeExpr->matches(nl->item(i), context, cs) )
|
||||
nodes->add(nl->item(i));
|
||||
Node* tmpNode = context->getFirstChild();
|
||||
while (tmpNode) {
|
||||
if ( nodeExpr->matches(tmpNode, context, cs) )
|
||||
nodes->add(tmpNode);
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* $Id: TextExpr.cpp,v 1.3 2001/04/11 15:01:03 axel%pike.org Exp $
|
||||
* $Id: TextExpr.cpp,v 1.4 2001/05/14 14:22:47 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
#include "Expr.h"
|
||||
|
@ -39,12 +39,11 @@ ExprResult* TextExpr::evaluate(Node* context, ContextState* cs) {
|
|||
|
||||
if ( !context ) return nodeSet;
|
||||
|
||||
NodeList* nl = context->getChildNodes();
|
||||
|
||||
for ( UInt32 i = 0; i < nl->getLength(); i++ ) {
|
||||
Node* node = nl->item(i);
|
||||
Node* node = context->getFirstChild();
|
||||
while (node) {
|
||||
if ( node->getNodeType() == Node::TEXT_NODE )
|
||||
nodeSet->add(node);
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
|
||||
return nodeSet;
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
* -- added code in ::resolveFunctionCall to support the
|
||||
* document() function.
|
||||
*
|
||||
* $Id: ProcessorState.cpp,v 1.25 2001/04/12 14:04:49 peterv%netscape.com Exp $
|
||||
* $Id: ProcessorState.cpp,v 1.26 2001/05/14 14:22:49 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of ProcessorState
|
||||
* Much of this code was ported from XSL:P
|
||||
* @version $Revision: 1.25 $ $Date: 2001/04/12 14:04:49 $
|
||||
* @version $Revision: 1.26 $ $Date: 2001/05/14 14:22:49 $
|
||||
**/
|
||||
|
||||
#include "ProcessorState.h"
|
||||
|
@ -138,9 +138,8 @@ void ProcessorState::addAttributeSet(Element* attributeSet) {
|
|||
}
|
||||
|
||||
//-- add xsl:attribute elements to attSet
|
||||
NodeList* nl = attributeSet->getChildNodes();
|
||||
for ( UInt32 i = 0; i < nl->getLength(); i++) {
|
||||
Node* node = nl->item(i);
|
||||
Node* node = attributeSet->getFirstChild();
|
||||
while (node) {
|
||||
if ( node->getNodeType() == Node::ELEMENT_NODE) {
|
||||
String nodeName = node->getNodeName();
|
||||
String ns;
|
||||
|
@ -150,6 +149,7 @@ void ProcessorState::addAttributeSet(Element* attributeSet) {
|
|||
XMLUtils::getLocalPart(nodeName, localPart);
|
||||
if ( ATTRIBUTE.isEqual(localPart) ) attSet->add(node);
|
||||
}
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
|
||||
} //-- addAttributeSet
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* Olivier Gerardin
|
||||
* -- Changed behavior of passing parameters to templates
|
||||
*
|
||||
* $Id: XSLTProcessor.cpp,v 1.44 2001/05/12 12:00:31 peterv%netscape.com Exp $
|
||||
* $Id: XSLTProcessor.cpp,v 1.45 2001/05/14 14:22:49 axel%pike.org Exp $
|
||||
*/
|
||||
|
||||
#include "XSLTProcessor.h"
|
||||
|
@ -72,7 +72,7 @@
|
|||
/**
|
||||
* XSLTProcessor is a class for Processing XSL stylesheets
|
||||
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
|
||||
* @version $Revision: 1.44 $ $Date: 2001/05/12 12:00:31 $
|
||||
* @version $Revision: 1.45 $ $Date: 2001/05/14 14:22:49 $
|
||||
**/
|
||||
|
||||
/**
|
||||
|
@ -207,11 +207,10 @@ String& XSLTProcessor::getAppVersion() {
|
|||
**/
|
||||
void XSLTProcessor::getHrefFromStylesheetPI(Document& xmlDocument, String& href) {
|
||||
|
||||
NodeList* nl = xmlDocument.getChildNodes();
|
||||
Node* node = xmlDocument.getFirstChild();
|
||||
String type;
|
||||
String tmpHref;
|
||||
for ( UInt32 i = 0; i < nl->getLength(); i++ ) {
|
||||
Node* node = nl->item(i);
|
||||
while (node) {
|
||||
if ( node->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE ) {
|
||||
String target = ((ProcessingInstruction*)node)->getTarget();
|
||||
if ( STYLESHEET_PI.isEqual(target) ||
|
||||
|
@ -226,6 +225,7 @@ void XSLTProcessor::getHrefFromStylesheetPI(Document& xmlDocument, String& href)
|
|||
}
|
||||
}
|
||||
}
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
|
||||
} //-- getHrefFromStylesheetPI
|
||||
|
@ -401,9 +401,8 @@ void XSLTProcessor::processTopLevel
|
|||
{
|
||||
if (!stylesheet) return;
|
||||
|
||||
NodeList* nl = stylesheet->getChildNodes();
|
||||
for (UInt32 i = 0; i < nl->getLength(); i++) {
|
||||
Node* node = nl->item(i);
|
||||
Node* node = stylesheet->getFirstChild();
|
||||
while (node) {
|
||||
if (node->getNodeType() == Node::ELEMENT_NODE) {
|
||||
Element* element = (Element*)node;
|
||||
String name = element->getNodeName();
|
||||
|
@ -533,6 +532,7 @@ void XSLTProcessor::processTopLevel
|
|||
break;
|
||||
}
|
||||
}
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
|
||||
} //-- process(Document, ProcessorState)
|
||||
|
@ -768,9 +768,8 @@ MBool XSLTProcessor::getText
|
|||
MBool flag = MB_TRUE;
|
||||
if ( deep ) XMLDOMUtils::getNodeValue(dfrag, &dest);
|
||||
else {
|
||||
NodeList* nl = dfrag->getChildNodes();
|
||||
for ( UInt32 i = 0; i < nl->getLength(); i++ ) {
|
||||
Node* node = nl->item(i);
|
||||
Node* node = dfrag->getFirstChild();
|
||||
while (node) {
|
||||
switch(node->getNodeType()) {
|
||||
case Node::CDATA_SECTION_NODE:
|
||||
case Node::TEXT_NODE :
|
||||
|
@ -780,6 +779,7 @@ MBool XSLTProcessor::getText
|
|||
if (allowOnlyTextNodes) flag = MB_FALSE;
|
||||
break;
|
||||
}
|
||||
node = node->getNextSibling();
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
|
@ -1006,11 +1006,13 @@ void XSLTProcessor::processAction
|
|||
// xsl:if
|
||||
case XSLType::CHOOSE :
|
||||
{
|
||||
NodeList* nl = actionElement->getChildNodes();
|
||||
Node* tmp = actionElement->getFirstChild();
|
||||
Element* xslTemplate = 0;
|
||||
for ( UInt32 i = 0; i < nl->getLength(); i++ ) {
|
||||
Node* tmp = nl->item(i);
|
||||
if ( tmp->getNodeType() != Node::ELEMENT_NODE ) continue;
|
||||
while (tmp) {
|
||||
if ( tmp->getNodeType() != Node::ELEMENT_NODE ) {
|
||||
tmp = tmp->getNextSibling();
|
||||
continue;
|
||||
}
|
||||
xslTemplate = (Element*)tmp;
|
||||
String nodeName = xslTemplate->getNodeName();
|
||||
switch ( getElementType(nodeName, ps) ) {
|
||||
|
@ -1030,6 +1032,7 @@ void XSLTProcessor::processAction
|
|||
default: //-- invalid xsl:choose child
|
||||
break;
|
||||
}
|
||||
tmp = tmp->getNextSibling();
|
||||
} //-- end for-each child of xsl:choose
|
||||
break;
|
||||
}
|
||||
|
@ -1369,9 +1372,10 @@ void XSLTProcessor::processAction
|
|||
}
|
||||
}
|
||||
//-- process children
|
||||
NodeList* nl = xslAction->getChildNodes();
|
||||
for ( UInt32 i = 0; i < nl->getLength(); i++) {
|
||||
processAction(node, nl->item(i),ps);
|
||||
Node* tmp = xslAction->getFirstChild();
|
||||
while (tmp) {
|
||||
processAction(node,tmp,ps);
|
||||
tmp = tmp->getNextSibling();
|
||||
}
|
||||
ps->getNodeStack()->pop();
|
||||
#ifdef MOZ_XSL
|
||||
|
@ -1461,9 +1465,8 @@ NamedMap* XSLTProcessor::processParameters(Element* xslAction, Node* context, Pr
|
|||
}
|
||||
|
||||
//-- handle xsl:with-param elements
|
||||
NodeList* nl = xslAction->getChildNodes();
|
||||
for (UInt32 i = 0; i < nl->getLength(); i++) {
|
||||
Node* tmpNode = nl->item(i);
|
||||
Node* tmpNode = xslAction->getFirstChild();
|
||||
while (tmpNode) {
|
||||
int nodeType = tmpNode->getNodeType();
|
||||
if ( nodeType == Node::ELEMENT_NODE ) {
|
||||
Element* action = (Element*)tmpNode;
|
||||
|
@ -1490,6 +1493,7 @@ NamedMap* XSLTProcessor::processParameters(Element* xslAction, Node* context, Pr
|
|||
}
|
||||
}
|
||||
}
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
return params;
|
||||
} //-- processParameters
|
||||
|
@ -1514,9 +1518,11 @@ void XSLTProcessor::processTemplate(Node* node, Node* xslTemplate, ProcessorStat
|
|||
localBindings.setObjectDeletion(MB_TRUE);
|
||||
bindings->push(&localBindings);
|
||||
processTemplateParams(xslTemplate, node, ps, params);
|
||||
NodeList* nl = xslTemplate->getChildNodes();
|
||||
for (UInt32 i = 0; i < nl->getLength(); i++)
|
||||
processAction(node, nl->item(i), ps);
|
||||
Node* tmp = xslTemplate->getFirstChild();
|
||||
while (tmp) {
|
||||
processAction(node,tmp,ps);
|
||||
tmp = tmp->getNextSibling();
|
||||
}
|
||||
bindings->pop();
|
||||
}
|
||||
} //-- processTemplate
|
||||
|
@ -1536,10 +1542,9 @@ void XSLTProcessor::processTemplateParams
|
|||
{
|
||||
|
||||
if ( xslTemplate ) {
|
||||
NodeList* nl = xslTemplate->getChildNodes();
|
||||
Node* tmpNode = xslTemplate->getFirstChild();
|
||||
//-- handle params
|
||||
for (UInt32 i = 0; i < nl->getLength(); i++) {
|
||||
Node* tmpNode = nl->item(i);
|
||||
while (tmpNode) {
|
||||
int nodeType = tmpNode->getNodeType();
|
||||
if ( nodeType == Node::ELEMENT_NODE ) {
|
||||
Element* action = (Element*)tmpNode;
|
||||
|
@ -1573,6 +1578,7 @@ void XSLTProcessor::processTemplateParams
|
|||
if (!XMLUtils::isWhitespace(((Text*)tmpNode)->getData())) break;
|
||||
}
|
||||
else break;
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
}
|
||||
} //-- processTemplateParams
|
||||
|
@ -1601,12 +1607,13 @@ ExprResult* XSLTProcessor::processVariable
|
|||
return expr->evaluate(node, ps);
|
||||
}
|
||||
else {
|
||||
NodeList* nl = xslVariable->getChildNodes();
|
||||
Node* tmpNode = xslVariable->getFirstChild();
|
||||
Document* resultTree = ps->getResultDocument();
|
||||
NodeStack* nodeStack = ps->getNodeStack();
|
||||
nodeStack->push(resultTree->createDocumentFragment());
|
||||
for (UInt32 i = 0; i < nl->getLength(); i++) {
|
||||
processAction(node, nl->item(i), ps);
|
||||
while (tmpNode) {
|
||||
processAction(node, tmpNode, ps);
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
Node* node = nodeStack->pop();
|
||||
//-- add clean up for This new NodeSet;
|
||||
|
|
Загрузка…
Ссылка в новой задаче