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