зеркало из https://github.com/mozilla/pjs.git
Rename Transformiix string API to be in synch with Mozilla's. Part of bug 74786 (String cleanup). r=sicking, rs=jst.
This commit is contained in:
Родитель
f71b3e75c3
Коммит
b2997dd663
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CommandLineUtils.h"
|
||||
|
||||
void CommandLineUtils::getOptions
|
||||
(NamedMap& options, int argc, char** argv, StringList& flags)
|
||||
{
|
||||
String arg;
|
||||
String flag;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
arg.clear();
|
||||
arg.append(argv[i]);
|
||||
|
||||
if (!arg.isEmpty() && (arg.charAt(0) == '-')) {
|
||||
|
||||
// clean up previous flag
|
||||
if (!flag.isEmpty()) {
|
||||
options.put(flag, new String(arg));
|
||||
flag.clear();
|
||||
}
|
||||
// get next flag
|
||||
arg.subString(1,flag);
|
||||
|
||||
//-- check full flag, otherwise try to find
|
||||
//-- flag within string
|
||||
if (!flags.contains(flag)) {
|
||||
PRUint32 idx = 1;
|
||||
String tmpFlag;
|
||||
while(idx <= flag.length()) {
|
||||
flag.subString(0,idx, tmpFlag);
|
||||
if (flags.contains(tmpFlag)) {
|
||||
if (idx < flag.length()) {
|
||||
String* value = new String();
|
||||
flag.subString(idx, *value);
|
||||
options.put(tmpFlag,value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (idx == flag.length()) {
|
||||
cout << "invalid option: -" << flag << endl;
|
||||
}
|
||||
++idx;
|
||||
}// end while
|
||||
}
|
||||
}// if flag char '-'
|
||||
else {
|
||||
// Store both flag key and number key
|
||||
if (!flag.isEmpty())
|
||||
options.put(flag, new String(arg));
|
||||
flag.clear();
|
||||
}
|
||||
|
||||
}// end for
|
||||
if (!flag.isEmpty())
|
||||
options.put(flag, new String("no value"));
|
||||
} //-- getOptions
|
||||
|
|
@ -132,35 +132,35 @@ MBool Double::isNeg(double aDbl)
|
|||
double Double::toDouble(const String& aSrc)
|
||||
{
|
||||
PRUint32 idx = 0;
|
||||
PRUint32 len = aSrc.length();
|
||||
PRUint32 len = aSrc.Length();
|
||||
MBool digitFound = MB_FALSE;
|
||||
|
||||
// leading whitespace
|
||||
while (idx < len &&
|
||||
XMLUtils::isWhitespace(aSrc.charAt(idx))) {
|
||||
XMLUtils::isWhitespace(aSrc.CharAt(idx))) {
|
||||
++idx;
|
||||
}
|
||||
|
||||
// sign char
|
||||
if (idx < len && aSrc.charAt(idx) == '-')
|
||||
if (idx < len && aSrc.CharAt(idx) == '-')
|
||||
++idx;
|
||||
|
||||
// integer chars
|
||||
while (idx < len &&
|
||||
aSrc.charAt(idx) >= '0' &&
|
||||
aSrc.charAt(idx) <= '9') {
|
||||
aSrc.CharAt(idx) >= '0' &&
|
||||
aSrc.CharAt(idx) <= '9') {
|
||||
++idx;
|
||||
digitFound = MB_TRUE;
|
||||
}
|
||||
|
||||
// decimal separator
|
||||
if (idx < len && aSrc.charAt(idx) == '.') {
|
||||
if (idx < len && aSrc.CharAt(idx) == '.') {
|
||||
++idx;
|
||||
|
||||
// fraction chars
|
||||
while (idx < len &&
|
||||
aSrc.charAt(idx) >= '0' &&
|
||||
aSrc.charAt(idx) <= '9') {
|
||||
aSrc.CharAt(idx) >= '0' &&
|
||||
aSrc.CharAt(idx) <= '9') {
|
||||
++idx;
|
||||
digitFound = MB_TRUE;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ double Double::toDouble(const String& aSrc)
|
|||
|
||||
// ending whitespace
|
||||
while (idx < len &&
|
||||
XMLUtils::isWhitespace(aSrc.charAt(idx))) {
|
||||
XMLUtils::isWhitespace(aSrc.CharAt(idx))) {
|
||||
++idx;
|
||||
}
|
||||
|
||||
|
@ -193,13 +193,13 @@ String& Double::toString(double aValue, String& aDest)
|
|||
// check for special cases
|
||||
|
||||
if (isNaN(aValue)) {
|
||||
aDest.append("NaN");
|
||||
aDest.Append(NS_LITERAL_STRING("NaN"));
|
||||
return aDest;
|
||||
}
|
||||
if (isInfinite(aValue)) {
|
||||
if (aValue < 0)
|
||||
aDest.append('-');
|
||||
aDest.append("Infinity");
|
||||
aDest.Append(PRUnichar('-'));
|
||||
aDest.Append(NS_LITERAL_STRING("Infinity"));
|
||||
return aDest;
|
||||
}
|
||||
|
||||
|
@ -222,17 +222,17 @@ String& Double::toString(double aValue, String& aDest)
|
|||
PR_dtoa(aValue, 0, 0, &intDigits, &sign, &endp, buf, bufsize-1);
|
||||
|
||||
if (sign)
|
||||
aDest.append('-');
|
||||
aDest.Append(PRUnichar('-'));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < endp - buf; i++) {
|
||||
if (i == intDigits)
|
||||
aDest.append('.');
|
||||
aDest.append(buf[i]);
|
||||
aDest.Append(PRUnichar('.'));
|
||||
aDest.Append(PRUnichar(buf[i]));
|
||||
}
|
||||
|
||||
for (; i < intDigits; i++)
|
||||
aDest.append('0');
|
||||
aDest.Append(PRUnichar('0'));
|
||||
|
||||
#else
|
||||
|
||||
|
@ -252,14 +252,14 @@ String& Double::toString(double aValue, String& aDest)
|
|||
}
|
||||
else {
|
||||
if (printDeci) {
|
||||
aDest.append('.');
|
||||
aDest.Append(PRUnichar('.'));
|
||||
printDeci = MB_FALSE;
|
||||
}
|
||||
|
||||
for ( ;zeros ;zeros--)
|
||||
aDest.append('0');
|
||||
aDest.Append(PRUnichar('0'));
|
||||
|
||||
aDest.append(buf[i]);
|
||||
aDest.Append(PRUnichar(buf[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ void NamedMap::put(const String& key, TxObject* obj) {
|
|||
//-- advance to next spot
|
||||
while ( bktItem ) {
|
||||
//-- if current key equals desired key, break
|
||||
if ( bktItem->key.isEqual(key) ) {
|
||||
if ( bktItem->key.Equals(key) ) {
|
||||
break;
|
||||
}
|
||||
prevItem = bktItem;
|
||||
|
@ -243,7 +243,7 @@ TxObject* NamedMap::remove(const String& key) {
|
|||
|
||||
BucketItem* bktItem = elements[idx];
|
||||
|
||||
while ( bktItem && !(key.isEqual(bktItem->key))) {
|
||||
while ( bktItem && !(key.Equals(bktItem->key))) {
|
||||
bktItem = bktItem->next;
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ NamedMap::BucketItem* NamedMap::getBucketItem(const String& key) {
|
|||
BucketItem* bktItem = elements[idx];
|
||||
|
||||
while ( bktItem ) {
|
||||
if ( bktItem->key.isEqual(key) ) return bktItem;
|
||||
if ( bktItem->key.Equals(key) ) return bktItem;
|
||||
bktItem = bktItem->next;
|
||||
}
|
||||
|
||||
|
@ -318,11 +318,11 @@ NamedMap::BucketItem* NamedMap::getBucketItem(const String& key) {
|
|||
**/
|
||||
unsigned long NamedMap::hashKey(const String& key)
|
||||
{
|
||||
PRUint32 len = key.length();
|
||||
PRUint32 len = key.Length();
|
||||
|
||||
unsigned long hashCode = 0;
|
||||
for (PRUint32 i = 0; i < len; ++i) {
|
||||
hashCode += ((PRInt32)key.charAt(i)) << 3;
|
||||
hashCode += ((PRInt32)key.CharAt(i)) << 3;
|
||||
}
|
||||
return hashCode;
|
||||
} //-- hashKey
|
||||
|
|
|
@ -1,318 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
* Bob Miller, kbob@oblix.com
|
||||
* -- plugged core leak.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* StringList
|
||||
**/
|
||||
|
||||
#include "StringList.h"
|
||||
|
||||
/**
|
||||
* Creates an empty list
|
||||
**/
|
||||
StringList::StringList() {
|
||||
firstItem = 0;
|
||||
lastItem = 0;
|
||||
itemCount = 0;
|
||||
} //-- StringList;
|
||||
|
||||
/**
|
||||
* StringList Destructor, Cleans up pointers and will delete the String
|
||||
* references, make sure you make copies of any needed Strings
|
||||
*/
|
||||
StringList::~StringList() {
|
||||
StringListItem* item = firstItem;
|
||||
while (item) {
|
||||
StringListItem* tItem = item;
|
||||
item = item->nextItem;
|
||||
delete tItem->strptr;
|
||||
delete tItem;
|
||||
}
|
||||
} //-- ~StringList
|
||||
|
||||
void StringList::add(String* strptr) {
|
||||
StringListItem* sItem = new StringListItem;
|
||||
if (sItem) {
|
||||
sItem->strptr = strptr;
|
||||
sItem->nextItem = 0;
|
||||
sItem->prevItem = lastItem;
|
||||
}
|
||||
if (lastItem) lastItem->nextItem = sItem;
|
||||
lastItem = sItem;
|
||||
if (!firstItem) firstItem = sItem;
|
||||
|
||||
// increase the item count
|
||||
++itemCount;
|
||||
} //-- add
|
||||
|
||||
MBool StringList::contains(String& search) {
|
||||
StringListItem* sItem = firstItem;
|
||||
while ( sItem ) {
|
||||
if ( search.isEqual(*sItem->strptr)) return MB_TRUE;
|
||||
sItem = sItem->nextItem;
|
||||
}
|
||||
return MB_FALSE;
|
||||
} //-- contains
|
||||
|
||||
/**
|
||||
* Returns the number of Strings in this List
|
||||
**/
|
||||
PRInt32 StringList::getLength() {
|
||||
return itemCount;
|
||||
} //-- getLength
|
||||
|
||||
|
||||
/**
|
||||
* Inserts the given String pointer as the item just after refItem.
|
||||
* If refItem is a null pointer the String will inserted at the
|
||||
* beginning of the List (ie, insert after nothing).
|
||||
* This method assumes refItem is a member of this list, and since this
|
||||
* is a private method, I feel that's a valid assumption
|
||||
**/
|
||||
void StringList::insertAfter(String* strptr, StringListItem* refItem) {
|
||||
|
||||
//-- if refItem == null insert at end
|
||||
if (!refItem) {
|
||||
if (firstItem) insertBefore(strptr, firstItem);
|
||||
else add(strptr);
|
||||
return;
|
||||
}
|
||||
|
||||
//-- if inserting at end of list
|
||||
if (refItem == lastItem) {
|
||||
add(strptr);
|
||||
return;
|
||||
}
|
||||
|
||||
//-- insert into middle of list
|
||||
StringListItem* sItem = new StringListItem;
|
||||
if (sItem) {
|
||||
sItem->strptr = strptr;
|
||||
sItem->prevItem = refItem;
|
||||
sItem->nextItem = refItem->nextItem;
|
||||
refItem->nextItem = sItem;
|
||||
|
||||
// increase the item count
|
||||
++itemCount;
|
||||
}
|
||||
} //-- insertAfter
|
||||
|
||||
/**
|
||||
* Inserts the given String pointer as the item just before refItem.
|
||||
* If refItem is a null pointer the String will inserted at the
|
||||
* end of the List (ie, insert before nothing).
|
||||
* This method assumes refItem is a member of this list, and since this
|
||||
* is a private method, I feel that's a valid assumption
|
||||
**/
|
||||
void StringList::insertBefore(String* strptr, StringListItem* refItem) {
|
||||
|
||||
//-- if refItem == null insert at end
|
||||
if (!refItem) {
|
||||
add(strptr);
|
||||
return;
|
||||
}
|
||||
|
||||
StringListItem* sItem = new StringListItem;
|
||||
if (sItem) {
|
||||
sItem->strptr = strptr;
|
||||
sItem->nextItem = refItem;
|
||||
sItem->prevItem = refItem->prevItem;
|
||||
refItem->prevItem = sItem;
|
||||
}
|
||||
|
||||
if (refItem == firstItem) firstItem = sItem;
|
||||
if (itemCount == 0) lastItem = sItem;
|
||||
|
||||
// increase the item count
|
||||
++itemCount;
|
||||
} //-- insertBefore
|
||||
|
||||
/**
|
||||
* Returns a StringListIterator for this StringList, this iterator
|
||||
* will need to be deleted by the caller.
|
||||
**/
|
||||
StringListIterator* StringList::iterator() {
|
||||
return new StringListIterator(this);
|
||||
} //-- iterator
|
||||
|
||||
String* StringList::remove(String* strptr) {
|
||||
StringListItem* sItem = firstItem;
|
||||
while (sItem) {
|
||||
if (sItem->strptr == strptr) {
|
||||
remove(sItem);
|
||||
delete sItem;
|
||||
return strptr;
|
||||
}
|
||||
sItem = sItem->nextItem;
|
||||
}
|
||||
// not in list
|
||||
return 0;
|
||||
} //-- remove
|
||||
|
||||
StringList::StringListItem* StringList::remove(StringList::StringListItem* sItem) {
|
||||
if (sItem->prevItem) {
|
||||
sItem->prevItem->nextItem = sItem->nextItem;
|
||||
}
|
||||
if (sItem == firstItem) firstItem = sItem->nextItem;
|
||||
if (sItem == lastItem) lastItem = sItem->prevItem;
|
||||
//-- decrease Item count
|
||||
--itemCount;
|
||||
return sItem;
|
||||
} //-- remove
|
||||
|
||||
/**
|
||||
* Removes all Strings equal to the given String from the list
|
||||
* All removed strings will be destroyed
|
||||
**/
|
||||
void StringList::remove(String& search) {
|
||||
StringListItem* sItem = firstItem;
|
||||
while (sItem) {
|
||||
if (sItem->strptr->isEqual(search)) {
|
||||
delete sItem->strptr;
|
||||
StringListItem* temp = remove(sItem);
|
||||
sItem = sItem->nextItem;
|
||||
delete temp;
|
||||
}
|
||||
else sItem = sItem->nextItem;
|
||||
}
|
||||
} //-- remove
|
||||
|
||||
//----------------------------------------/
|
||||
//- Implementation of StringListIterator -/
|
||||
//----------------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new StringListIterator for the given StringList
|
||||
**/
|
||||
StringListIterator::StringListIterator(StringList* list) {
|
||||
stringList = list;
|
||||
currentItem = 0;
|
||||
allowRemove = MB_FALSE;
|
||||
} //-- StringListIterator
|
||||
|
||||
StringListIterator::~StringListIterator() {
|
||||
//-- overrides default destructor to do nothing
|
||||
} //-- ~StringListIterator
|
||||
|
||||
/**
|
||||
* Adds the String pointer to the StringList of this StringListIterator.
|
||||
* The String pointer is inserted as the next item in the StringList
|
||||
* based on the current position within the StringList
|
||||
**/
|
||||
void StringListIterator::add(String* strptr) {
|
||||
|
||||
stringList->insertAfter(strptr,currentItem);
|
||||
allowRemove = MB_FALSE;
|
||||
|
||||
} //-- add
|
||||
|
||||
/**
|
||||
* Returns true if a sucessful call to the next() method can be made
|
||||
**/
|
||||
MBool StringListIterator::hasNext() {
|
||||
if (currentItem) {
|
||||
return (currentItem->nextItem != 0);
|
||||
}
|
||||
return (stringList->firstItem != 0);
|
||||
} //-- hasNext
|
||||
|
||||
/**
|
||||
* Returns true if a successful call to the previous() method can be made
|
||||
**/
|
||||
MBool StringListIterator::hasPrevious() {
|
||||
if (currentItem) {
|
||||
return (currentItem->prevItem != 0);
|
||||
}
|
||||
return MB_FALSE;
|
||||
} //-- hasPrevious
|
||||
|
||||
/**
|
||||
* Returns the next String in the list
|
||||
**/
|
||||
String* StringListIterator::next() {
|
||||
|
||||
if (currentItem) {
|
||||
if (currentItem->nextItem) {
|
||||
currentItem = currentItem->nextItem;
|
||||
allowRemove = MB_TRUE;
|
||||
return currentItem->strptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
currentItem = stringList->firstItem;
|
||||
allowRemove = MB_TRUE;
|
||||
if (currentItem)
|
||||
return currentItem->strptr;
|
||||
}
|
||||
return 0;
|
||||
} //-- next
|
||||
|
||||
/**
|
||||
* Returns the previous String in the list
|
||||
**/
|
||||
String* StringListIterator::previous() {
|
||||
|
||||
if (currentItem) {
|
||||
if (currentItem->prevItem) {
|
||||
currentItem = currentItem->prevItem;
|
||||
allowRemove = MB_TRUE;
|
||||
return currentItem->strptr;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//-- prev
|
||||
|
||||
/**
|
||||
* Removes the String last return by the next() or previous();
|
||||
* The removed String* is returned
|
||||
**/
|
||||
String* StringListIterator::remove() {
|
||||
|
||||
if (allowRemove == MB_FALSE) return 0;
|
||||
|
||||
allowRemove = MB_FALSE;
|
||||
|
||||
StringList::StringListItem* sItem = 0;
|
||||
if (currentItem) {
|
||||
// Make previous Item the current Item or null
|
||||
sItem = currentItem;
|
||||
if (stringList->firstItem == sItem) currentItem = 0;
|
||||
stringList->remove(sItem);
|
||||
return sItem->strptr;
|
||||
}
|
||||
return 0;
|
||||
} //-- remove
|
||||
|
||||
/**
|
||||
* Resets the current location within the StringList to the beginning
|
||||
**/
|
||||
void StringListIterator::reset() {
|
||||
currentItem = 0;
|
||||
} //-- reset
|
|
@ -64,12 +64,12 @@ txTokenizer::txTokenizer(const String& aSource)
|
|||
{
|
||||
mCurrentPos = 0;
|
||||
mSource = aSource;
|
||||
mSize = mSource.length();
|
||||
mSize = mSource.Length();
|
||||
|
||||
// Advance to start pos
|
||||
while (mCurrentPos < mSize) {
|
||||
// If character is not a whitespace, we are at start of first token
|
||||
if (!XMLUtils::isWhitespace(mSource.charAt(mCurrentPos)))
|
||||
if (!XMLUtils::isWhitespace(mSource.CharAt(mCurrentPos)))
|
||||
break;
|
||||
++mCurrentPos;
|
||||
}
|
||||
|
@ -82,19 +82,19 @@ MBool txTokenizer::hasMoreTokens()
|
|||
|
||||
void txTokenizer::nextToken(String& aBuffer)
|
||||
{
|
||||
aBuffer.clear();
|
||||
aBuffer.Truncate();
|
||||
while (mCurrentPos < mSize) {
|
||||
UNICODE_CHAR ch = mSource.charAt(mCurrentPos++);
|
||||
PRUnichar ch = mSource.CharAt(mCurrentPos++);
|
||||
// If character is not a delimiter we append it
|
||||
if (XMLUtils::isWhitespace(ch))
|
||||
break;
|
||||
aBuffer.append(ch);
|
||||
aBuffer.Append(ch);
|
||||
}
|
||||
|
||||
// Advance to next start pos
|
||||
while (mCurrentPos < mSize) {
|
||||
// If character is not a whitespace, we are at start of next token
|
||||
if (!XMLUtils::isWhitespace(mSource.charAt(mCurrentPos)))
|
||||
if (!XMLUtils::isWhitespace(mSource.CharAt(mCurrentPos)))
|
||||
break;
|
||||
++mCurrentPos;
|
||||
}
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
/* -*- 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
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Tom Kneeland
|
||||
* -- original author.
|
||||
*
|
||||
* Keith Visco <kvisco@ziplink.net>
|
||||
* Larry Fitzpatrick
|
||||
*
|
||||
*/
|
||||
|
||||
#include "TxString.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
String::String(const UNICODE_CHAR* aSource, PRUint32 aLength)
|
||||
{
|
||||
if (aLength) {
|
||||
mString = Substring(aSource, aSource + aLength);
|
||||
}
|
||||
else {
|
||||
mString = nsDependentString(aSource);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
txCaseInsensitiveStringComparator::operator()(const char_type* lhs,
|
||||
const char_type* rhs,
|
||||
PRUint32 aLength ) const
|
||||
{
|
||||
UNICODE_CHAR thisChar, otherChar;
|
||||
PRUint32 compLoop = 0;
|
||||
while (compLoop < aLength) {
|
||||
thisChar = lhs[compLoop];
|
||||
if ((thisChar >= 'A') && (thisChar <= 'Z')) {
|
||||
thisChar += 32;
|
||||
}
|
||||
otherChar = rhs[compLoop];
|
||||
if ((otherChar >= 'A') && (otherChar <= 'Z')) {
|
||||
otherChar += 32;
|
||||
}
|
||||
if (thisChar != otherChar) {
|
||||
return thisChar - otherChar;
|
||||
}
|
||||
++compLoop;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
txCaseInsensitiveStringComparator::operator()(char_type lhs,
|
||||
char_type rhs) const
|
||||
{
|
||||
if (lhs >= 'A' && lhs <= 'Z') {
|
||||
lhs += 32;
|
||||
}
|
||||
if (rhs >= 'A' && rhs <= 'Z') {
|
||||
rhs += 32;
|
||||
}
|
||||
return lhs - rhs;
|
||||
}
|
||||
|
||||
void String::toLowerCase()
|
||||
{
|
||||
nsAFlatString::char_iterator c, e;
|
||||
mString.BeginWriting(c);
|
||||
mString.EndWriting(e);
|
||||
while (c != e) {
|
||||
if (*c >= 'A' && *c <= 'Z')
|
||||
*c += 32;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
void String::toUpperCase()
|
||||
{
|
||||
nsAFlatString::char_iterator c, e;
|
||||
mString.BeginWriting(c);
|
||||
mString.EndWriting(e);
|
||||
while (c != e) {
|
||||
if (*c >= 'a' && *c <= 'z')
|
||||
*c -= 32;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& aOutput, const String& aSource)
|
||||
{
|
||||
aOutput << NS_LossyConvertUCS2toASCII(aSource.mString).get();
|
||||
return aOutput;
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Tom Kneeland
|
||||
* -- original author.
|
||||
*
|
||||
* Keith Visco <kvisco@ziplink.net>
|
||||
* Larry Fitzpatrick
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef txString_h__
|
||||
#define txString_h__
|
||||
|
||||
#include "baseutils.h"
|
||||
|
||||
#include "TxObject.h"
|
||||
#include <iostream.h>
|
||||
#include "nsString.h"
|
||||
typedef PRUnichar UNICODE_CHAR;
|
||||
|
||||
#ifdef TX_EXE
|
||||
class txCaseInsensitiveStringComparator
|
||||
: public nsStringComparator
|
||||
{
|
||||
public:
|
||||
virtual int operator()(const char_type*, const char_type*, PRUint32 aLength) const;
|
||||
virtual int operator()(char_type, char_type) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
class String
|
||||
: public TxObject
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Default constructor.
|
||||
*/
|
||||
String();
|
||||
|
||||
/*
|
||||
* Copying constructor.
|
||||
*/
|
||||
String(const String& aSource);
|
||||
|
||||
#ifdef TX_EXE
|
||||
/*
|
||||
* Constructor, allocates a buffer and copies the supplied string buffer.
|
||||
* If aLength is zero it computes the length from the supplied string.
|
||||
*/
|
||||
explicit String(const UNICODE_CHAR* aSource, PRUint32 aLength = 0);
|
||||
#endif
|
||||
explicit String(const nsAString& aSource);
|
||||
~String();
|
||||
|
||||
/*
|
||||
* Append aSource to this string.
|
||||
*/
|
||||
void append(UNICODE_CHAR aSource);
|
||||
void append(const String& aSource);
|
||||
void append(const UNICODE_CHAR* aSource, PRUint32 aLength);
|
||||
void append(const nsAString& aSource);
|
||||
|
||||
/*
|
||||
* Insert aSource at aOffset in this string.
|
||||
*/
|
||||
void insert(PRUint32 aOffset, UNICODE_CHAR aSource);
|
||||
void insert(PRUint32 aOffset, const String& aSource);
|
||||
|
||||
/*
|
||||
* Replace characters starting at aOffset with aSource.
|
||||
*/
|
||||
void replace(PRUint32 aOffset, UNICODE_CHAR aSource);
|
||||
void replace(PRUint32 aOffset, const String& aSource);
|
||||
|
||||
/*
|
||||
* Delete aCount characters starting at aOffset.
|
||||
*/
|
||||
void deleteChars(PRUint32 aOffset, PRUint32 aCount);
|
||||
|
||||
/*
|
||||
* Returns the character at aIndex. Caller needs to check the
|
||||
* index for out-of-bounds errors.
|
||||
*/
|
||||
UNICODE_CHAR charAt(PRUint32 aIndex) const;
|
||||
|
||||
/*
|
||||
* Clear the string.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/*
|
||||
* Returns index of first occurrence of aData.
|
||||
*/
|
||||
PRInt32 indexOf(UNICODE_CHAR aData,
|
||||
PRInt32 aOffset = 0) const;
|
||||
PRInt32 indexOf(const String& aData, PRInt32 aOffset = 0) const;
|
||||
|
||||
/*
|
||||
* Returns index of last occurrence of aData.
|
||||
*/
|
||||
PRInt32 lastIndexOf(UNICODE_CHAR aData,
|
||||
PRInt32 aOffset = -1) const;
|
||||
|
||||
/*
|
||||
* Check equality between strings.
|
||||
*/
|
||||
MBool isEqual(const String& aData) const;
|
||||
|
||||
/*
|
||||
* Check equality (ignoring case) between strings.
|
||||
*/
|
||||
MBool isEqualIgnoreCase(const String& aData) const;
|
||||
|
||||
/*
|
||||
* Check whether the string is empty.
|
||||
*/
|
||||
MBool isEmpty() const;
|
||||
|
||||
/*
|
||||
* Return the length of the string.
|
||||
*/
|
||||
PRUint32 length() const;
|
||||
|
||||
/*
|
||||
* Returns a substring starting at start
|
||||
* Note: the dest String is cleared before use
|
||||
*/
|
||||
String& subString(PRUint32 aStart, String& aDest) const;
|
||||
|
||||
/*
|
||||
* Returns the subString starting at start and ending at end
|
||||
* Note: the dest String is cleared before use
|
||||
*/
|
||||
String& subString(PRUint32 aStart, PRUint32 aEnd,
|
||||
String& aDest) const;
|
||||
|
||||
/*
|
||||
* Convert string to lowercase.
|
||||
*/
|
||||
void toLowerCase();
|
||||
|
||||
/*
|
||||
* Convert string to uppercase.
|
||||
*/
|
||||
void toUpperCase();
|
||||
|
||||
/*
|
||||
* Shorten the string to aLength.
|
||||
*/
|
||||
void truncate(PRUint32 aLength);
|
||||
|
||||
/*
|
||||
* Return a reference to this string's nsString.
|
||||
*/
|
||||
operator nsAString&();
|
||||
|
||||
/*
|
||||
* Return a const reference to this string's nsString.
|
||||
*/
|
||||
operator const nsAString&() const;
|
||||
|
||||
private:
|
||||
nsString mString;
|
||||
|
||||
friend ostream& operator << (ostream& aOutput, const String& aSource);
|
||||
|
||||
// XXX DEPRECATED
|
||||
public:
|
||||
explicit String(PRUint32 aSize);
|
||||
explicit String(const char* aSource); // XXX Used for literal strings
|
||||
void append(const char* aSource);
|
||||
MBool isEqual(const char* aData) const;
|
||||
nsString& getNSString();
|
||||
const nsString& getConstNSString() const;
|
||||
// XXX DEPRECATED
|
||||
};
|
||||
|
||||
/*
|
||||
* Translate UNICODE_CHARs to Chars and output to the provided stream.
|
||||
*/
|
||||
ostream& operator << (ostream& aOutput, const String& aSource);
|
||||
|
||||
// txMozillaString.h contains all inline implementations for the
|
||||
// Mozilla module.
|
||||
#include "txMozillaString.h"
|
||||
|
||||
#endif // txString_h__
|
|
@ -1,259 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef txMozillaString_h__
|
||||
#define txMozillaString_h__
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#ifndef TX_EXE
|
||||
#include "nsUnicharUtils.h"
|
||||
typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
|
||||
#endif
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(String)
|
||||
|
||||
inline String::String()
|
||||
{
|
||||
MOZ_COUNT_CTOR(String);
|
||||
}
|
||||
|
||||
inline String::String(const String& aSource) : mString(aSource.mString)
|
||||
{
|
||||
MOZ_COUNT_CTOR(String);
|
||||
}
|
||||
|
||||
inline String::String(const nsAString& aSource) : mString(aSource)
|
||||
{
|
||||
MOZ_COUNT_CTOR(String);
|
||||
}
|
||||
|
||||
inline String::~String()
|
||||
{
|
||||
MOZ_COUNT_DTOR(String);
|
||||
}
|
||||
|
||||
inline void String::append(UNICODE_CHAR aSource)
|
||||
{
|
||||
mString.Append(aSource);
|
||||
}
|
||||
|
||||
inline void String::append(const String& aSource)
|
||||
{
|
||||
mString.Append(aSource.mString);
|
||||
}
|
||||
|
||||
inline void String::append(const UNICODE_CHAR* aSource, PRUint32 aLength)
|
||||
{
|
||||
mString.Append(aSource, aLength);
|
||||
}
|
||||
|
||||
inline void String::append(const nsAString& aSource)
|
||||
{
|
||||
mString.Append(aSource);
|
||||
}
|
||||
|
||||
inline void String::insert(PRUint32 aOffset,
|
||||
UNICODE_CHAR aSource)
|
||||
{
|
||||
mString.Insert(aSource, aOffset);
|
||||
}
|
||||
|
||||
inline void String::insert(PRUint32 aOffset, const String& aSource)
|
||||
{
|
||||
mString.Insert(aSource.mString, aOffset);
|
||||
}
|
||||
|
||||
inline void String::replace(PRUint32 aOffset,
|
||||
UNICODE_CHAR aSource)
|
||||
{
|
||||
mString.SetCharAt(aSource, aOffset);
|
||||
}
|
||||
|
||||
inline void String::replace(PRUint32 aOffset, const String& aSource)
|
||||
{
|
||||
mString.Replace(aOffset, mString.Length() - aOffset, aSource.mString);
|
||||
}
|
||||
|
||||
inline void String::deleteChars(PRUint32 aOffset,
|
||||
PRUint32 aCount)
|
||||
{
|
||||
mString.Cut(aOffset, aCount);
|
||||
}
|
||||
|
||||
inline UNICODE_CHAR String::charAt(PRUint32 aIndex) const
|
||||
{
|
||||
return mString.CharAt(aIndex);
|
||||
}
|
||||
|
||||
inline void String::clear()
|
||||
{
|
||||
mString.Truncate();
|
||||
}
|
||||
|
||||
inline PRInt32 String::indexOf(UNICODE_CHAR aData,
|
||||
PRInt32 aOffset) const
|
||||
{
|
||||
return mString.FindChar(aData, (PRUint32)aOffset);
|
||||
}
|
||||
|
||||
inline PRInt32 String::indexOf(const String& aData,
|
||||
PRInt32 aOffset) const
|
||||
{
|
||||
return mString.Find(aData.mString, aOffset);
|
||||
}
|
||||
|
||||
inline PRInt32 String::lastIndexOf(UNICODE_CHAR aData,
|
||||
PRInt32 aOffset) const
|
||||
{
|
||||
return mString.RFindChar(aData, aOffset);
|
||||
}
|
||||
|
||||
inline MBool String::isEqual(const String& aData) const
|
||||
{
|
||||
if (this == &aData)
|
||||
return MB_TRUE;
|
||||
return mString.Equals(aData.mString);
|
||||
}
|
||||
|
||||
inline MBool String::isEqualIgnoreCase(const String& aData) const
|
||||
{
|
||||
if (this == &aData)
|
||||
return MB_TRUE;
|
||||
return mString.Equals(aData.mString, txCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
inline MBool String::isEmpty() const
|
||||
{
|
||||
return mString.IsEmpty();
|
||||
}
|
||||
|
||||
inline PRUint32 String::length() const
|
||||
{
|
||||
return mString.Length();
|
||||
}
|
||||
|
||||
inline void String::truncate(PRUint32 aLength)
|
||||
{
|
||||
mString.Truncate(aLength);
|
||||
}
|
||||
|
||||
inline String& String::subString(PRUint32 aStart, String& aDest) const
|
||||
{
|
||||
PRUint32 length = mString.Length();
|
||||
if (aStart < length) {
|
||||
aDest.mString.Assign(Substring(mString, aStart, length - aStart));
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(aStart == length,
|
||||
"Bonehead! Calling subString with negative length.");
|
||||
aDest.clear();
|
||||
}
|
||||
return aDest;
|
||||
}
|
||||
|
||||
inline String& String::subString(PRUint32 aStart, PRUint32 aEnd,
|
||||
String& aDest) const
|
||||
{
|
||||
if (aStart < aEnd) {
|
||||
aDest.mString.Assign(Substring(mString, aStart, aEnd - aStart));
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(aStart == aEnd,
|
||||
"Bonehead! Calling subString with negative length.");
|
||||
aDest.clear();
|
||||
}
|
||||
return aDest;
|
||||
}
|
||||
|
||||
#ifndef TX_EXE
|
||||
inline void String::toLowerCase()
|
||||
{
|
||||
ToLowerCase(mString);
|
||||
}
|
||||
|
||||
inline void String::toUpperCase()
|
||||
{
|
||||
ToUpperCase(mString);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline String::operator nsAString&()
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
inline String::operator const nsAString&() const
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
// XXX DEPRECATED
|
||||
inline String::String(PRUint32 aSize)
|
||||
{
|
||||
MOZ_COUNT_CTOR(String);
|
||||
mString.SetCapacity(aSize);
|
||||
}
|
||||
|
||||
inline String::String(const char* aSource)
|
||||
{
|
||||
MOZ_COUNT_CTOR(String);
|
||||
mString.AssignWithConversion(aSource);
|
||||
}
|
||||
|
||||
inline void String::append(const char* aSource)
|
||||
{
|
||||
mString.AppendWithConversion(aSource);
|
||||
}
|
||||
|
||||
inline MBool String::isEqual(const char* aData) const
|
||||
{
|
||||
return mString.EqualsWithConversion(aData);
|
||||
}
|
||||
|
||||
inline nsString& String::getNSString()
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
inline const nsString& String::getConstNSString() const
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
#endif // txMozillaString_h__
|
|
@ -50,8 +50,8 @@
|
|||
#ifdef TX_EXE
|
||||
//- Constants -/
|
||||
|
||||
const String URIUtils::HTTP_PROTOCOL("http");
|
||||
const String URIUtils::FILE_PROTOCOL("file");
|
||||
const String URIUtils::HTTP_PROTOCOL(NS_LITERAL_STRING("http"));
|
||||
const String URIUtils::FILE_PROTOCOL(NS_LITERAL_STRING("file"));
|
||||
const char URIUtils::HREF_PATH_SEP = '/';
|
||||
const char URIUtils::DEVICE_SEP = '|';
|
||||
const char URIUtils::PORT_SEP = ':';
|
||||
|
@ -97,28 +97,28 @@ istream* URIUtils::getInputStream
|
|||
**/
|
||||
void URIUtils::getDocumentBase(const String& href, String& dest) {
|
||||
//-- use temp str so the subString method doesn't destroy dest
|
||||
String docBase("");
|
||||
String docBase;
|
||||
|
||||
if (!href.isEmpty()) {
|
||||
if (!href.IsEmpty()) {
|
||||
|
||||
int idx = -1;
|
||||
//-- check for URL
|
||||
ParsedURI* uri = parseURI(href);
|
||||
if ( !uri->isMalformed ) {
|
||||
idx = href.lastIndexOf(HREF_PATH_SEP);
|
||||
idx = href.RFindChar(HREF_PATH_SEP);
|
||||
}
|
||||
else {
|
||||
//-- The following contains a fix from Shane Hathaway
|
||||
//-- to handle the case when both "\" and "/" appear in filename
|
||||
int idx2 = href.lastIndexOf(HREF_PATH_SEP);
|
||||
//idx = href.lastIndexOf(File.separator);
|
||||
int idx2 = href.RFindChar(HREF_PATH_SEP);
|
||||
//idx = href.RFindChar(File.separator);
|
||||
idx = -1; //-- hack change later
|
||||
if (idx2 > idx) idx = idx2;
|
||||
}
|
||||
if (idx >= 0) href.subString(0,idx, docBase);
|
||||
delete uri;
|
||||
}
|
||||
dest.append(docBase);
|
||||
dest.Append(docBase);
|
||||
} //-- getDocumentBase
|
||||
#endif
|
||||
|
||||
|
@ -129,12 +129,12 @@ void URIUtils::getDocumentBase(const String& href, String& dest) {
|
|||
**/
|
||||
void URIUtils::resolveHref(const String& href, const String& base,
|
||||
String& dest) {
|
||||
if (base.isEmpty()) {
|
||||
dest.append(href);
|
||||
if (base.IsEmpty()) {
|
||||
dest.Append(href);
|
||||
return;
|
||||
}
|
||||
if (href.isEmpty()) {
|
||||
dest.append(base);
|
||||
if (href.IsEmpty()) {
|
||||
dest.Append(base);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ void URIUtils::resolveHref(const String& href, const String& base,
|
|||
nsresult result = NS_NewURI(getter_AddRefs(pURL), base);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
NS_MakeAbsoluteURI(resultHref, href, pURL);
|
||||
dest.append(resultHref);
|
||||
dest.Append(resultHref);
|
||||
}
|
||||
#else
|
||||
String documentBase;
|
||||
|
@ -153,7 +153,7 @@ void URIUtils::resolveHref(const String& href, const String& base,
|
|||
//-- check for URL
|
||||
ParsedURI* uri = parseURI(href);
|
||||
if ( !uri->isMalformed ) {
|
||||
dest.append(href);
|
||||
dest.Append(href);
|
||||
delete uri;
|
||||
return;
|
||||
}
|
||||
|
@ -161,24 +161,24 @@ void URIUtils::resolveHref(const String& href, const String& base,
|
|||
|
||||
//-- join document base + href
|
||||
String xHref;
|
||||
if (!documentBase.isEmpty()) {
|
||||
xHref.append(documentBase);
|
||||
if (documentBase.charAt(documentBase.length()-1) != HREF_PATH_SEP)
|
||||
xHref.append(HREF_PATH_SEP);
|
||||
if (!documentBase.IsEmpty()) {
|
||||
xHref.Append(documentBase);
|
||||
if (documentBase.CharAt(documentBase.Length()-1) != HREF_PATH_SEP)
|
||||
xHref.Append(PRUnichar(HREF_PATH_SEP));
|
||||
}
|
||||
xHref.append(href);
|
||||
xHref.Append(href);
|
||||
|
||||
//-- check new href
|
||||
ParsedURI* newUri = parseURI(xHref);
|
||||
if ( !newUri->isMalformed ) {
|
||||
dest.append(xHref);
|
||||
dest.Append(xHref);
|
||||
}
|
||||
else {
|
||||
// Try local files
|
||||
ifstream inFile(NS_LossyConvertUCS2toASCII(xHref).get(),
|
||||
ios::in);
|
||||
if ( inFile ) dest.append(xHref);
|
||||
else dest.append(href);
|
||||
if ( inFile ) dest.Append(xHref);
|
||||
else dest.Append(href);
|
||||
inFile.close();
|
||||
}
|
||||
delete uri;
|
||||
|
@ -189,16 +189,16 @@ void URIUtils::resolveHref(const String& href, const String& base,
|
|||
|
||||
void URIUtils::getFragmentIdentifier(const String& href, String& frag) {
|
||||
PRInt32 pos;
|
||||
pos = href.lastIndexOf('#');
|
||||
pos = href.RFindChar('#');
|
||||
if(pos != kNotFound)
|
||||
href.subString(pos+1, frag);
|
||||
else
|
||||
frag.clear();
|
||||
frag.Truncate();
|
||||
} //-- getFragmentIdentifier
|
||||
|
||||
void URIUtils::getDocumentURI(const String& href, String& docUri) {
|
||||
PRInt32 pos;
|
||||
pos = href.lastIndexOf('#');
|
||||
pos = href.RFindChar('#');
|
||||
if(pos != kNotFound)
|
||||
href.subString(0,pos,docUri);
|
||||
else
|
||||
|
@ -211,7 +211,7 @@ istream* URIUtils::openStream(ParsedURI* uri) {
|
|||
// check protocol
|
||||
|
||||
istream* inStream = 0;
|
||||
if ( FILE_PROTOCOL.isEqual(uri->protocol) ) {
|
||||
if ( FILE_PROTOCOL.Equals(uri->protocol) ) {
|
||||
ifstream* inFile =
|
||||
new ifstream(NS_LossyConvertUCS2toASCII(uri->path).get(),
|
||||
ios::in);
|
||||
|
@ -231,32 +231,33 @@ URIUtils::ParsedURI* URIUtils::parseURI(const String& uri) {
|
|||
short mode = PROTOCOL_MODE;
|
||||
|
||||
// look for protocol
|
||||
int totalCount = uri.length();
|
||||
int totalCount = uri.Length();
|
||||
int charCount = 0;
|
||||
UNICODE_CHAR prevCh = '\0';
|
||||
PRUnichar prevCh = '\0';
|
||||
int fslash = 0;
|
||||
String buffer(uri.length());
|
||||
String buffer;
|
||||
buffer.getNSString().SetCapacity(uri.Length());
|
||||
while ( charCount < totalCount ) {
|
||||
UNICODE_CHAR ch = uri.charAt(charCount++);
|
||||
PRUnichar ch = uri.CharAt(charCount++);
|
||||
switch(ch) {
|
||||
case '.' :
|
||||
if ( mode == PROTOCOL_MODE ) {
|
||||
uriTokens->isMalformed = MB_TRUE;
|
||||
mode = HOST_MODE;
|
||||
}
|
||||
buffer.append(ch);
|
||||
buffer.Append(ch);
|
||||
break;
|
||||
case ':' :
|
||||
{
|
||||
switch ( mode ) {
|
||||
case PROTOCOL_MODE :
|
||||
uriTokens->protocol = buffer;
|
||||
buffer.clear();
|
||||
buffer.Truncate();
|
||||
mode = HOST_MODE;
|
||||
break;
|
||||
case HOST_MODE :
|
||||
uriTokens->host = buffer;
|
||||
buffer.clear();
|
||||
buffer.Truncate();
|
||||
mode = PORT_MODE;
|
||||
break;
|
||||
default:
|
||||
|
@ -267,25 +268,25 @@ URIUtils::ParsedURI* URIUtils::parseURI(const String& uri) {
|
|||
case '/' :
|
||||
switch ( mode ) {
|
||||
case HOST_MODE :
|
||||
if (!buffer.isEmpty()) {
|
||||
if (!buffer.IsEmpty()) {
|
||||
mode = PATH_MODE;
|
||||
buffer.append(ch);
|
||||
buffer.Append(ch);
|
||||
}
|
||||
else if ( fslash == 2 ) mode = PATH_MODE;
|
||||
else ++fslash;
|
||||
break;
|
||||
case PORT_MODE :
|
||||
mode = PATH_MODE;
|
||||
uriTokens->port.append(buffer);
|
||||
buffer.clear();
|
||||
uriTokens->port.Append(buffer);
|
||||
buffer.Truncate();
|
||||
break;
|
||||
default:
|
||||
buffer.append(ch);
|
||||
buffer.Append(ch);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
buffer.append(ch);
|
||||
buffer.Append(ch);
|
||||
}
|
||||
prevCh = ch;
|
||||
}
|
||||
|
@ -294,19 +295,19 @@ URIUtils::ParsedURI* URIUtils::parseURI(const String& uri) {
|
|||
uriTokens->isMalformed = MB_TRUE;
|
||||
}
|
||||
//-- finish remaining mode
|
||||
if (!buffer.isEmpty()) {
|
||||
if (!buffer.IsEmpty()) {
|
||||
switch ( mode ) {
|
||||
case PROTOCOL_MODE :
|
||||
uriTokens->protocol.append(buffer);
|
||||
uriTokens->protocol.Append(buffer);
|
||||
break;
|
||||
case HOST_MODE :
|
||||
uriTokens->host.append(buffer);
|
||||
uriTokens->host.Append(buffer);
|
||||
break;
|
||||
case PORT_MODE :
|
||||
uriTokens->port.append(buffer);
|
||||
uriTokens->port.Append(buffer);
|
||||
break;
|
||||
case PATH_MODE :
|
||||
uriTokens->path.append(buffer);
|
||||
uriTokens->path.Append(buffer);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -66,41 +66,41 @@ int main(int argc, char** argv) {
|
|||
|
||||
//-- available flags
|
||||
StringList flags;
|
||||
flags.add(new String("i")); // XML input
|
||||
flags.add(new String("s")); // XSL input
|
||||
flags.add(new String("o")); // Output filename
|
||||
flags.add(new String("h")); // help
|
||||
flags.add(new String("q")); // quiet
|
||||
flags.add(new String(NS_LITERAL_STRING("i"))); // XML input
|
||||
flags.add(new String(NS_LITERAL_STRING("s"))); // XSL input
|
||||
flags.add(new String(NS_LITERAL_STRING("o"))); // Output filename
|
||||
flags.add(new String(NS_LITERAL_STRING("h"))); // help
|
||||
flags.add(new String(NS_LITERAL_STRING("q"))); // quiet
|
||||
|
||||
NamedMap options;
|
||||
options.setObjectDeletion(MB_TRUE);
|
||||
CommandLineUtils::getOptions(options, argc, argv, flags);
|
||||
|
||||
if (!options.get(String("q"))) {
|
||||
String copyright("(C) 1999 The MITRE Corporation, Keith Visco, and contributors");
|
||||
if (!options.get(String(NS_LITERAL_STRING("q")))) {
|
||||
String copyright(NS_LITERAL_STRING("(C) 1999 The MITRE Corporation, Keith Visco, and contributors"));
|
||||
cerr << "TransforMiiX ";
|
||||
cerr << "1.2b pre" << endl;
|
||||
cerr << copyright << endl;
|
||||
//-- print banner line
|
||||
PRUint32 fillSize = copyright.length() + 1;
|
||||
PRUint32 fillSize = copyright.Length() + 1;
|
||||
PRUint32 counter;
|
||||
for (counter = 0; counter < fillSize; ++counter)
|
||||
cerr << '-';
|
||||
cerr << endl << endl;
|
||||
}
|
||||
|
||||
if (options.get(String("h"))) {
|
||||
if (options.get(String(NS_LITERAL_STRING("h")))) {
|
||||
printHelp();
|
||||
return 0;
|
||||
}
|
||||
String* xmlFilename = (String*)options.get(String("i"));
|
||||
String* xsltFilename = (String*)options.get(String("s"));
|
||||
String* outFilename = (String*)options.get(String("o"));
|
||||
String* xmlFilename = (String*)options.get(String(NS_LITERAL_STRING("i")));
|
||||
String* xsltFilename = (String*)options.get(String(NS_LITERAL_STRING("s")));
|
||||
String* outFilename = (String*)options.get(String(NS_LITERAL_STRING("o")));
|
||||
|
||||
//-- handle output stream
|
||||
ostream* resultOutput = &cout;
|
||||
ofstream resultFileStream;
|
||||
if (outFilename && !outFilename->isEqual("-")) {
|
||||
if (outFilename && !outFilename->getConstNSString().Equals(NS_LITERAL_STRING("-"))) {
|
||||
resultFileStream.open(NS_LossyConvertUCS2toASCII(*outFilename).get(),
|
||||
ios::out);
|
||||
if (!resultFileStream) {
|
||||
|
|
|
@ -58,13 +58,13 @@ public:
|
|||
int loadStylesheet (char * filename)
|
||||
{
|
||||
delete mXSL;
|
||||
mXSL = parsePath(String(filename), mObserver);
|
||||
mXSL = parsePath(String(NS_ConvertASCIItoUCS2(filename)), mObserver);
|
||||
return mXSL ? 0 : 1;
|
||||
}
|
||||
int setInputDocument (char * filename)
|
||||
{
|
||||
delete mXML;
|
||||
mXML = parsePath(String(filename), mObserver);
|
||||
mXML = parsePath(String(NS_ConvertASCIItoUCS2(filename)), mObserver);
|
||||
return mXML ? 0 : 1;
|
||||
}
|
||||
int openOutput (char * outputFilename)
|
||||
|
|
|
@ -41,7 +41,7 @@ void XMLDOMUtils::getNodeValue(Node* aNode, String& aResult)
|
|||
case Node::PROCESSING_INSTRUCTION_NODE:
|
||||
case Node::TEXT_NODE:
|
||||
{
|
||||
aResult.append(aNode->getNodeValue());
|
||||
aResult.Append(aNode->getNodeValue());
|
||||
break;
|
||||
}
|
||||
case Node::DOCUMENT_NODE:
|
||||
|
@ -58,7 +58,7 @@ void XMLDOMUtils::getNodeValue(Node* aNode, String& aResult)
|
|||
nodeType = tmpNode->getNodeType();
|
||||
if ((nodeType == Node::TEXT_NODE) ||
|
||||
(nodeType == Node::CDATA_SECTION_NODE))
|
||||
aResult.append(tmpNode->getNodeValue());
|
||||
aResult.Append(tmpNode->getNodeValue());
|
||||
else if (nodeType == Node::ELEMENT_NODE)
|
||||
getNodeValue(tmpNode, aResult);
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
|
|
|
@ -81,7 +81,7 @@ void XMLUtils::getPrefix(const String& src, String& dest)
|
|||
NS_ASSERTION(idx > 0, "This QName looks invalid.");
|
||||
String tmp;
|
||||
src.subString(0, (PRUint32)idx, tmp);
|
||||
dest.append(tmp);
|
||||
dest.Append(tmp);
|
||||
}
|
||||
|
||||
void XMLUtils::getLocalPart(const String& src, String& dest)
|
||||
|
@ -89,7 +89,7 @@ void XMLUtils::getLocalPart(const String& src, String& dest)
|
|||
// Anything after ':' is the local part of the name
|
||||
PRInt32 idx = src.indexOf(':');
|
||||
if (idx == kNotFound) {
|
||||
dest.append(src);
|
||||
dest.Append(src);
|
||||
return;
|
||||
}
|
||||
// Use a temporary String to prevent any chars in dest
|
||||
|
@ -97,24 +97,24 @@ void XMLUtils::getLocalPart(const String& src, String& dest)
|
|||
NS_ASSERTION(idx > 0, "This QName looks invalid.");
|
||||
String tmp;
|
||||
src.subString((PRUint32)idx + 1, tmp);
|
||||
dest.append(tmp);
|
||||
dest.Append(tmp);
|
||||
}
|
||||
|
||||
MBool XMLUtils::isValidQName(const String& aName)
|
||||
{
|
||||
if (aName.isEmpty()) {
|
||||
if (aName.IsEmpty()) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
if (!isLetter(aName.charAt(0))) {
|
||||
if (!isLetter(aName.CharAt(0))) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
PRUint32 size = aName.length();
|
||||
PRUint32 size = aName.Length();
|
||||
PRUint32 i;
|
||||
MBool foundColon = MB_FALSE;
|
||||
for (i = 1; i < size; ++i) {
|
||||
UNICODE_CHAR character = aName.charAt(i);
|
||||
PRUnichar character = aName.CharAt(i);
|
||||
if (character == ':') {
|
||||
foundColon = MB_TRUE;
|
||||
++i;
|
||||
|
@ -129,11 +129,11 @@ MBool XMLUtils::isValidQName(const String& aName)
|
|||
// a valid QName.
|
||||
return !foundColon;
|
||||
}
|
||||
if (!isLetter(aName.charAt(i))) {
|
||||
if (!isLetter(aName.CharAt(i))) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
for (++i; i < size; ++i) {
|
||||
if (!isNCNameChar(aName.charAt(i))) {
|
||||
if (!isNCNameChar(aName.CharAt(i))) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -163,18 +163,18 @@ MBool XMLUtils::isWhitespace(const String& aText)
|
|||
void XMLUtils::normalizePIValue(String& piValue)
|
||||
{
|
||||
String origValue(piValue);
|
||||
PRUint32 origLength = origValue.length();
|
||||
PRUint32 origLength = origValue.Length();
|
||||
PRUint32 conversionLoop = 0;
|
||||
UNICODE_CHAR prevCh = 0;
|
||||
piValue.clear();
|
||||
PRUnichar prevCh = 0;
|
||||
piValue.Truncate();
|
||||
|
||||
while (conversionLoop < origLength) {
|
||||
UNICODE_CHAR ch = origValue.charAt(conversionLoop);
|
||||
PRUnichar ch = origValue.CharAt(conversionLoop);
|
||||
switch (ch) {
|
||||
case '>':
|
||||
{
|
||||
if (prevCh == '?') {
|
||||
piValue.append(' ');
|
||||
piValue.Append(PRUnichar(' '));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ void XMLUtils::normalizePIValue(String& piValue)
|
|||
break;
|
||||
}
|
||||
}
|
||||
piValue.append(ch);
|
||||
piValue.Append(ch);
|
||||
prevCh = ch;
|
||||
++conversionLoop;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ MBool XMLUtils::getXMLSpacePreserve(Node* aNode)
|
|||
#define TX_MATCH_CHAR(ch, a) if (ch < a) return MB_FALSE; \
|
||||
if (ch == a) return MB_TRUE
|
||||
|
||||
MBool XMLUtils::isDigit(UNICODE_CHAR ch)
|
||||
MBool XMLUtils::isDigit(PRUnichar ch)
|
||||
{
|
||||
TX_CHAR_RANGE(ch, 0x0030, 0x0039); /* '0'-'9' */
|
||||
TX_CHAR_RANGE(ch, 0x0660, 0x0669);
|
||||
|
@ -246,7 +246,7 @@ MBool XMLUtils::isDigit(UNICODE_CHAR ch)
|
|||
return MB_FALSE;
|
||||
}
|
||||
|
||||
MBool XMLUtils::isLetter(UNICODE_CHAR ch)
|
||||
MBool XMLUtils::isLetter(PRUnichar ch)
|
||||
{
|
||||
/* Letter = BaseChar | Ideographic; and _ */
|
||||
TX_CHAR_RANGE(ch, 0x0041, 0x005A);
|
||||
|
@ -458,7 +458,7 @@ MBool XMLUtils::isLetter(UNICODE_CHAR ch)
|
|||
return MB_FALSE;
|
||||
}
|
||||
|
||||
MBool XMLUtils::isNCNameChar(UNICODE_CHAR ch)
|
||||
MBool XMLUtils::isNCNameChar(PRUnichar ch)
|
||||
{
|
||||
/* NCNameChar = Letter | Digit | '.' | '-' | '_' |
|
||||
CombiningChar | Extender */
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
/*
|
||||
* Returns true if the given character is whitespace.
|
||||
*/
|
||||
static MBool isWhitespace(const UNICODE_CHAR& aChar)
|
||||
static MBool isWhitespace(const PRUnichar& aChar)
|
||||
{
|
||||
return (aChar <= ' ' &&
|
||||
(aChar == ' ' || aChar == '\r' ||
|
||||
|
@ -126,17 +126,17 @@ public:
|
|||
/*
|
||||
* Returns true if the given character represents a numeric letter (digit).
|
||||
*/
|
||||
static MBool isDigit(UNICODE_CHAR ch);
|
||||
static MBool isDigit(PRUnichar ch);
|
||||
|
||||
/*
|
||||
* Returns true if the given character represents an Alpha letter
|
||||
*/
|
||||
static MBool isLetter(UNICODE_CHAR ch);
|
||||
static MBool isLetter(PRUnichar ch);
|
||||
|
||||
/*
|
||||
* Returns true if the given character is an allowable NCName character
|
||||
*/
|
||||
static MBool isNCNameChar(UNICODE_CHAR ch);
|
||||
static MBool isNCNameChar(PRUnichar ch);
|
||||
|
||||
/*
|
||||
* Walks up the document tree and returns true if the closest xml:space
|
||||
|
|
|
@ -80,7 +80,7 @@ MBool Element::getAttr(txAtom* aLocalName, PRInt32 aNSID,
|
|||
nsCOMPtr<nsIContent> cont(do_QueryInterface(mMozObject));
|
||||
NS_ASSERTION(cont, "Element doesn't implement nsIContent");
|
||||
if (!cont || !cont->HasAttr(aNSID, aLocalName)) {
|
||||
aValue.clear();
|
||||
aValue.Truncate();
|
||||
return MB_FALSE;
|
||||
}
|
||||
nsresult rv;
|
||||
|
|
|
@ -55,8 +55,6 @@
|
|||
typedef 0 NULL;
|
||||
#endif
|
||||
|
||||
typedef UNICODE_CHAR DOM_CHAR;
|
||||
|
||||
#define kTxNsNodeIndexOffset 0x00000000;
|
||||
#define kTxAttrIndexOffset 0x40000000;
|
||||
#define kTxChildIndexOffset 0x80000000;
|
||||
|
|
|
@ -70,7 +70,7 @@ Attr::Attr(const String& aNamespaceURI,
|
|||
Document* aOwner) :
|
||||
NodeDefinition(Node::ATTRIBUTE_NODE, aName, NULL_STRING, aOwner)
|
||||
{
|
||||
if (aNamespaceURI.isEmpty())
|
||||
if (aNamespaceURI.IsEmpty())
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
else
|
||||
mNamespaceID = txNamespaceManager::getNamespaceID(aNamespaceURI);
|
||||
|
@ -116,10 +116,10 @@ const String& Attr::getValue()
|
|||
Node* child = getFirstChild();
|
||||
while (child) {
|
||||
if (child->getNodeType() != Node::ENTITY_REFERENCE_NODE) {
|
||||
nodeValue.append(child->getNodeValue());
|
||||
nodeValue.Append(child->getNodeValue());
|
||||
child = child->getNextSibling();
|
||||
if (child)
|
||||
nodeValue.append(",");
|
||||
nodeValue.Append(PRUnichar(','));
|
||||
} else {
|
||||
child = child->getNextSibling();
|
||||
}
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
// Tom Kneeland (3/29/99)
|
||||
//
|
||||
// Implementation of the Document Object Model Level 1 Core
|
||||
// Implementation of the CDATASection class
|
||||
//
|
||||
// Modification History:
|
||||
// Who When What
|
||||
// TK 03/29/99 Created
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
|
||||
//
|
||||
//Construct a text object with the specified document owner and data
|
||||
//
|
||||
CDATASection::CDATASection(const String& theData, Document* owner) :
|
||||
Text(Node::CDATA_SECTION_NODE, String("#cdata-section"), theData, owner)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//CDATASection nodes can not have any children, so just return null from all child
|
||||
//manipulation functions.
|
||||
//
|
||||
|
||||
Node* CDATASection::insertBefore(Node* newChild, Node* refChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* CDATASection::replaceChild(Node* newChild, Node* oldChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* CDATASection::removeChild(Node* oldChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* CDATASection::appendChild(Node* newChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
// Tom Kneeland (3/29/99)
|
||||
//
|
||||
// Implementation of the Document Object Model Level 1 Core
|
||||
// Implementation of the CharacterData class
|
||||
//
|
||||
// Modification History:
|
||||
// Who When What
|
||||
// TK 03/29/99 Created
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
|
||||
//
|
||||
//Protected constructor. Just pass parameters onto NodeDefinition.
|
||||
//
|
||||
CharacterData::CharacterData(NodeType type, const String& name,
|
||||
const String& value, Document* owner) :
|
||||
NodeDefinition(type, name, value, owner)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//Return a constant reference to the data stored by this object.
|
||||
//
|
||||
const String& CharacterData::getData() const
|
||||
{
|
||||
return nodeValue;
|
||||
}
|
||||
|
||||
//
|
||||
//Set the data stored by this object to the string represented by "source".
|
||||
//
|
||||
void CharacterData::setData(const String& source)
|
||||
{
|
||||
nodeValue = source;
|
||||
}
|
||||
|
||||
//
|
||||
//Returns the length of the data object.
|
||||
//
|
||||
PRUint32 CharacterData::getLength() const
|
||||
{
|
||||
return nodeValue.length();
|
||||
}
|
||||
|
||||
//
|
||||
//Retreive the substring starting at offset anc ending count number of
|
||||
//characters away.
|
||||
// NOTE: An empty string will be returned in the event of an error.
|
||||
//
|
||||
String& CharacterData::substringData(PRUint32 offset, PRUint32 count, String& dest)
|
||||
{
|
||||
if ((offset < nodeValue.length()) && (count > 0))
|
||||
return nodeValue.subString(offset, offset+count, dest);
|
||||
else
|
||||
{
|
||||
dest.clear();
|
||||
return dest;
|
||||
}
|
||||
}
|
||||
|
||||
void CharacterData::appendData(const String& arg)
|
||||
{
|
||||
nodeValue.append(arg);
|
||||
}
|
||||
|
||||
void CharacterData::insertData(PRUint32 offset, const String& arg)
|
||||
{
|
||||
if (offset < nodeValue.length())
|
||||
nodeValue.insert(offset, arg);
|
||||
}
|
||||
|
||||
void CharacterData::deleteData(PRUint32 offset, PRUint32 count)
|
||||
{
|
||||
if ((offset < nodeValue.length()) && (count > 0))
|
||||
nodeValue.deleteChars(offset, count);
|
||||
}
|
||||
|
||||
void CharacterData::replaceData(PRUint32 offset, PRUint32 count, const String& arg)
|
||||
{
|
||||
String tempString;
|
||||
|
||||
if ((offset < nodeValue.length()) && (count > 0))
|
||||
{
|
||||
if (count < arg.length())
|
||||
{
|
||||
tempString = arg.subString(0, count, tempString);
|
||||
nodeValue.replace(offset, tempString);
|
||||
}
|
||||
else
|
||||
nodeValue.replace(offset, arg);
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
// Tom Kneeland (3/29/99)
|
||||
//
|
||||
// Implementation of the Document Object Model Level 1 Core
|
||||
// Implementation of the Comment class
|
||||
//
|
||||
// Modification History:
|
||||
// Who When What
|
||||
// TK 03/29/99 Created
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
|
||||
//
|
||||
//Construct a text object with the specified document owner and data
|
||||
//
|
||||
Comment::Comment(const String& theData, Document* owner) :
|
||||
CharacterData(Node::COMMENT_NODE, String("#comment"), theData, owner)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//Comment nodes can not have any children, so just return null from all child
|
||||
//manipulation functions.
|
||||
//
|
||||
|
||||
Node* Comment::insertBefore(Node* newChild, Node* refChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* Comment::replaceChild(Node* newChild, Node* oldChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* Comment::removeChild(Node* oldChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* Comment::appendChild(Node* newChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
// Tom Kneeland (3/29/99)
|
||||
//
|
||||
// Implementation of the Document Object Model Level 1 Core
|
||||
// Implementation of the DOMImplementation class
|
||||
//
|
||||
// Modification History:
|
||||
// Who When What
|
||||
// TK 03/29/99 Created
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
|
||||
DOMImplementation::DOMImplementation() : implFeature("XML"),
|
||||
implVersion("1.0")
|
||||
{
|
||||
}
|
||||
|
||||
DOMImplementation::~DOMImplementation()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//Perform a case insensitive comparison between "feature" and the
|
||||
//functionality of this DOM implementation/version.
|
||||
//
|
||||
MBool DOMImplementation::hasFeature(String feature,
|
||||
const String& version) const
|
||||
{
|
||||
feature.toUpperCase();
|
||||
|
||||
if (feature.isEqual(implFeature) && version.isEqual(implVersion))
|
||||
return MB_TRUE;
|
||||
else
|
||||
return MB_FALSE;
|
||||
}
|
|
@ -38,7 +38,7 @@
|
|||
//node constructor is called to identify the node type.
|
||||
//
|
||||
Document::Document(DocumentType* theDoctype) :
|
||||
NodeDefinition(Node::DOCUMENT_NODE, String("#document"), NULL_STRING, NULL)
|
||||
NodeDefinition(Node::DOCUMENT_NODE, String(NS_LITERAL_STRING("#document")), NULL_STRING, NULL)
|
||||
{
|
||||
documentElement = NULL;
|
||||
doctype = theDoctype;
|
||||
|
@ -195,7 +195,7 @@ Node* Document::removeChild(Node* oldChild)
|
|||
//
|
||||
DocumentFragment* Document::createDocumentFragment()
|
||||
{
|
||||
return new DocumentFragment(String("#document-fragment"), NULL_STRING, this);
|
||||
return new DocumentFragment(String(NS_LITERAL_STRING("#document-fragment")), NULL_STRING, this);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -57,7 +57,7 @@ Element::Element(const String& aNamespaceURI,
|
|||
NodeDefinition(Node::ELEMENT_NODE, aTagName, NULL_STRING, aOwner)
|
||||
{
|
||||
Element(aTagName, aOwner);
|
||||
if (aNamespaceURI.isEmpty())
|
||||
if (aNamespaceURI.IsEmpty())
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
else
|
||||
mNamespaceID = txNamespaceManager::getNamespaceID(aNamespaceURI);
|
||||
|
@ -100,7 +100,7 @@ PRInt32 Element::getNamespaceID()
|
|||
if (((Element*)node)->getAttr(txXMLAtoms::xmlns, kNameSpaceID_XMLNS,
|
||||
nsURI)) {
|
||||
// xmlns = "" sets the default namespace ID to kNameSpaceID_None;
|
||||
if (!nsURI.isEmpty()) {
|
||||
if (!nsURI.IsEmpty()) {
|
||||
mNamespaceID = txNamespaceManager::getNamespaceID(nsURI);
|
||||
}
|
||||
else {
|
||||
|
@ -263,7 +263,7 @@ Attr* Element::getAttributeNode(const String& name)
|
|||
MBool Element::getAttr(txAtom* aLocalName, PRInt32 aNSID,
|
||||
String& aValue)
|
||||
{
|
||||
aValue.clear();
|
||||
aValue.Truncate();
|
||||
AttrMap::ListItem* item = mAttributes.firstItem;
|
||||
while (item) {
|
||||
Attr* attrNode = (Attr*)item->node;
|
||||
|
@ -271,7 +271,7 @@ MBool Element::getAttr(txAtom* aLocalName, PRInt32 aNSID,
|
|||
if (attrNode->getLocalName(&localName) &&
|
||||
aNSID == attrNode->getNamespaceID() &&
|
||||
aLocalName == localName) {
|
||||
aValue.append(attrNode->getValue());
|
||||
aValue.Append(attrNode->getValue());
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ NodeListDefinition::ListItem*
|
|||
|
||||
while (pSearchItem)
|
||||
{
|
||||
if (name.isEqual(pSearchItem->node->getNodeName()))
|
||||
if (name.Equals(pSearchItem->node->getNodeName()))
|
||||
return pSearchItem;
|
||||
|
||||
pSearchItem = pSearchItem->next;
|
||||
|
|
|
@ -389,17 +389,17 @@ PRInt32 NodeDefinition::lookupNamespaceID(txAtom* aPrefix)
|
|||
if (node->getNodeType() != Node::ELEMENT_NODE)
|
||||
node = node->getXPathParent();
|
||||
|
||||
String name("xmlns:");
|
||||
String name(NS_LITERAL_STRING("xmlns:"));
|
||||
if (aPrefix && (aPrefix != txXMLAtoms::_empty)) {
|
||||
// We have a prefix, search for xmlns:prefix attributes.
|
||||
String prefixString;
|
||||
TX_GET_ATOM_STRING(aPrefix, prefixString);
|
||||
name.append(prefixString);
|
||||
name.Append(prefixString);
|
||||
}
|
||||
else {
|
||||
// No prefix, look up the default namespace by searching for xmlns
|
||||
// attributes. Remove the trailing :, set length to 5 (xmlns).
|
||||
name.truncate(5);
|
||||
name.Truncate(5);
|
||||
}
|
||||
Attr* xmlns;
|
||||
while (node && node->getNodeType() == Node::ELEMENT_NODE) {
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
// Tom Kneeland (3/29/99)
|
||||
//
|
||||
// Implementation of the Document Object Model Level 1 Core
|
||||
// Implementation of the Text class
|
||||
//
|
||||
// Modification History:
|
||||
// Who When What
|
||||
// TK 03/29/99 Created
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
|
||||
//
|
||||
//Construct a text object with the specified document owner and data
|
||||
//
|
||||
Text::Text(const String& theData, Document* owner) :
|
||||
CharacterData(Node::TEXT_NODE, String("#text"), theData, owner)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
//Protected constructor for children of the Text Class. Currently only
|
||||
//CDATASection needs to use this function.
|
||||
Text::Text(NodeType type, const String& name, const String& value,
|
||||
Document* owner) :
|
||||
CharacterData(type, name, value, owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//Split the text node at Offset into two siblings. Return a pointer to the new
|
||||
//sibling.
|
||||
//
|
||||
Text* Text::splitText(PRUint32 offset)
|
||||
{
|
||||
Text* newTextSibling = NULL;
|
||||
String newData;
|
||||
|
||||
if (offset < nodeValue.length())
|
||||
{
|
||||
newTextSibling = getOwnerDocument()->createTextNode(nodeValue.subString(offset, newData));
|
||||
getParentNode()->insertBefore(newTextSibling, getNextSibling());
|
||||
nodeValue.deleteChars(offset, nodeValue.length() - offset);
|
||||
}
|
||||
|
||||
return newTextSibling;
|
||||
}
|
||||
|
||||
//
|
||||
//Text nodes can not have any children, so just return null from all child
|
||||
//manipulation functions.
|
||||
//
|
||||
|
||||
Node* Text::insertBefore(Node* newChild, Node* refChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* Text::replaceChild(Node* newChild, Node* oldChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* Text::removeChild(Node* oldChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Node* Text::appendChild(Node* newChild)
|
||||
{
|
||||
return NULL;
|
||||
}
|
|
@ -46,8 +46,6 @@
|
|||
typedef 0 NULL;
|
||||
#endif
|
||||
|
||||
typedef UNICODE_CHAR DOM_CHAR;
|
||||
|
||||
#define kTxNsNodeIndexOffset 0x00000000;
|
||||
#define kTxAttrIndexOffset 0x40000000;
|
||||
#define kTxChildIndexOffset 0x80000000;
|
||||
|
@ -711,7 +709,7 @@ public:
|
|||
while (nameIter.hasNext()) {
|
||||
uri = (String*)nameIter.next();
|
||||
id++;
|
||||
if (uri->isEqual(aURI))
|
||||
if (uri->Equals(aURI))
|
||||
return id;
|
||||
}
|
||||
uri = new String(aURI);
|
||||
|
@ -752,21 +750,21 @@ public:
|
|||
* xmlns prefix is 1, mapped to http://www.w3.org/2000/xmlns/
|
||||
* xml prefix is 2, mapped to http://www.w3.org/XML/1998/namespace
|
||||
*/
|
||||
String* XMLNSUri = new String("http://www.w3.org/2000/xmlns/");
|
||||
String* XMLNSUri = new String(NS_LITERAL_STRING("http://www.w3.org/2000/xmlns/"));
|
||||
if (!XMLNSUri) {
|
||||
delete mNamespaces;
|
||||
mNamespaces = 0;
|
||||
return MB_FALSE;
|
||||
}
|
||||
mNamespaces->add(XMLNSUri);
|
||||
String* XMLUri = new String("http://www.w3.org/XML/1998/namespace");
|
||||
String* XMLUri = new String(NS_LITERAL_STRING("http://www.w3.org/XML/1998/namespace"));
|
||||
if (!XMLUri) {
|
||||
delete mNamespaces;
|
||||
mNamespaces = 0;
|
||||
return MB_FALSE;
|
||||
}
|
||||
mNamespaces->add(XMLUri);
|
||||
String* XSLTUri = new String("http://www.w3.org/1999/XSL/Transform");
|
||||
String* XSLTUri = new String(NS_LITERAL_STRING("http://www.w3.org/1999/XSL/Transform"));
|
||||
if (!XSLTUri) {
|
||||
delete mNamespaces;
|
||||
mNamespaces = 0;
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
*
|
||||
* Marina Mechtcheriakova, mmarina@mindspring.com
|
||||
* -- UNICODE fix in method startElement, changed casting of
|
||||
* char* to DOM_CHAR* to use the proper String constructor,
|
||||
* char* to PRUnichar* to use the proper String constructor,
|
||||
* see method startElement
|
||||
* -- Removed a number of castings of XML_Char to DOM_CHAR since they
|
||||
* -- Removed a number of castings of XML_Char to PRUnichar since they
|
||||
* were not working on Windows properly
|
||||
*
|
||||
*/
|
||||
|
@ -91,9 +91,9 @@ Document* XMLParser::getDocumentFromURI(const String& href,
|
|||
NS_ENSURE_SUCCESS(rv, 0);
|
||||
rv = loader->LoadDocument(channel, loaderUri, getter_AddRefs(theDocument));
|
||||
if (NS_FAILED(rv) || !theDocument) {
|
||||
errMsg.append("Document load of ");
|
||||
errMsg.append(href);
|
||||
errMsg.append(" failed.");
|
||||
errMsg.Append(NS_LITERAL_STRING("Document load of "));
|
||||
errMsg.Append(href);
|
||||
errMsg.Append(NS_LITERAL_STRING(" failed."));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ Document* XMLParser::getDocumentFromURI(const String& href,
|
|||
delete xslInput;
|
||||
}
|
||||
if (!resultDoc) {
|
||||
errMsg.append(getErrorString());
|
||||
errMsg.Append(getErrorString());
|
||||
}
|
||||
return resultDoc;
|
||||
#endif
|
||||
|
@ -136,9 +136,9 @@ Document* XMLParser::parse(istream& inputStream, const String& uri)
|
|||
|
||||
char buf[bufferSize];
|
||||
int done;
|
||||
errorString.clear();
|
||||
errorString.Truncate();
|
||||
if ( !inputStream ) {
|
||||
errorString.append("unable to parse xml: invalid or unopen stream encountered.");
|
||||
errorString.Append(NS_LITERAL_STRING("unable to parse xml: invalid or unopen stream encountered."));
|
||||
return NULL;
|
||||
}
|
||||
XML_Parser parser = XML_ParserCreate(NULL);
|
||||
|
@ -159,9 +159,9 @@ Document* XMLParser::parse(istream& inputStream, const String& uri)
|
|||
|
||||
if (!XML_Parse(parser, buf, inputStream.gcount(), done))
|
||||
{
|
||||
errorString.append(XML_ErrorString(XML_GetErrorCode(parser)));
|
||||
errorString.append(" at line ");
|
||||
errorString.append(XML_GetCurrentLineNumber(parser));
|
||||
errorString.getNSString().AppendWithConversion(XML_ErrorString(XML_GetErrorCode(parser)));
|
||||
errorString.Append(NS_LITERAL_STRING(" at line "));
|
||||
errorString.getNSString().AppendInt(XML_GetCurrentLineNumber(parser));
|
||||
done = MB_TRUE;
|
||||
delete ps.document;
|
||||
ps.document = NULL;
|
||||
|
@ -190,13 +190,13 @@ int startElement(void *userData, const XML_Char *name, const XML_Char **atts)
|
|||
Element* newElement;
|
||||
XML_Char** theAtts = (XML_Char**)atts;
|
||||
|
||||
String nodeName((UNICODE_CHAR *)name);
|
||||
String nodeName((PRUnichar *)name);
|
||||
newElement = ps->document->createElement(nodeName);
|
||||
|
||||
while (*theAtts)
|
||||
{
|
||||
String attName((UNICODE_CHAR *)*theAtts++);
|
||||
String attValue((UNICODE_CHAR *)*theAtts++);
|
||||
String attName((PRUnichar *)*theAtts++);
|
||||
String attValue((PRUnichar *)*theAtts++);
|
||||
newElement->setAttribute(attName, attValue);
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ int endElement(void *userData, const XML_Char* name)
|
|||
void charData(void* userData, const XML_Char* s, int len)
|
||||
{
|
||||
ParserState* ps = (ParserState*)userData;
|
||||
String data((UNICODE_CHAR*)s, len);
|
||||
String data((PRUnichar*)s, len);
|
||||
Node* prevSib = ps->currentNode->getLastChild();
|
||||
if (prevSib && prevSib->getNodeType()==Node::TEXT_NODE){
|
||||
((CharacterData*)prevSib)->appendData(data);
|
||||
|
@ -229,7 +229,7 @@ void charData(void* userData, const XML_Char* s, int len)
|
|||
void commentHandler(void* userData, const XML_Char* s)
|
||||
{
|
||||
ParserState* ps = (ParserState*)userData;
|
||||
String data((UNICODE_CHAR*)s);
|
||||
String data((PRUnichar*)s);
|
||||
ps->currentNode->appendChild(ps->document->createComment(data));
|
||||
} //-- commentHandler
|
||||
|
||||
|
@ -238,8 +238,8 @@ void commentHandler(void* userData, const XML_Char* s)
|
|||
**/
|
||||
int piHandler(void *userData, const XML_Char *target, const XML_Char *data) {
|
||||
ParserState* ps = (ParserState*)userData;
|
||||
String targetStr((UNICODE_CHAR *)target);
|
||||
String dataStr((UNICODE_CHAR *)data);
|
||||
String targetStr((PRUnichar *)target);
|
||||
String dataStr((PRUnichar *)data);
|
||||
|
||||
ps->currentNode->appendChild(
|
||||
ps->document->createProcessingInstruction(targetStr, dataStr));
|
||||
|
|
|
@ -97,18 +97,18 @@ ExprResult* AdditiveExpr::evaluate(txIEvalContext* aContext)
|
|||
void AdditiveExpr::toString(String& str) {
|
||||
|
||||
if ( leftExpr ) leftExpr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
|
||||
switch ( op ) {
|
||||
case SUBTRACTION:
|
||||
str.append(" - ");
|
||||
str.Append(NS_LITERAL_STRING(" - "));
|
||||
break;
|
||||
default:
|
||||
str.append(" + ");
|
||||
str.Append(NS_LITERAL_STRING(" + "));
|
||||
break;
|
||||
}
|
||||
if ( rightExpr ) rightExpr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
|
||||
} //-- toString
|
||||
|
||||
|
|
|
@ -83,10 +83,10 @@ ExprResult* AttributeValueTemplate::evaluate(txIEvalContext* aContext)
|
|||
void AttributeValueTemplate::toString(String& str) {
|
||||
txListIterator iter(&expressions);
|
||||
while (iter.hasNext()) {
|
||||
str.append('{');
|
||||
str.Append(PRUnichar('{'));
|
||||
Expr* expr = (Expr*)iter.next();
|
||||
expr->toString(str);
|
||||
str.append('}');
|
||||
str.Append(PRUnichar('}'));
|
||||
}
|
||||
} //-- toString
|
||||
|
||||
|
|
|
@ -95,18 +95,18 @@ ExprResult* BooleanExpr::evaluate(txIEvalContext* aContext)
|
|||
void BooleanExpr::toString(String& str) {
|
||||
|
||||
if ( leftExpr ) leftExpr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
|
||||
switch ( op ) {
|
||||
case OR:
|
||||
str.append(" or ");
|
||||
str.Append(NS_LITERAL_STRING(" or "));
|
||||
break;
|
||||
default:
|
||||
str.append(" and ");
|
||||
str.Append(NS_LITERAL_STRING(" and "));
|
||||
break;
|
||||
}
|
||||
if ( rightExpr ) rightExpr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
|
||||
} //-- toString
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ ExprResult* BooleanFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case TX_BOOLEAN:
|
||||
{
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
return new BooleanResult(evaluateToBoolean((Expr*)iter.next(),
|
||||
aContext));
|
||||
|
@ -63,7 +63,7 @@ ExprResult* BooleanFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case TX_LANG:
|
||||
{
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String lang;
|
||||
Node* node = aContext->getContextNode();
|
||||
|
@ -84,8 +84,8 @@ ExprResult* BooleanFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
arg.toUpperCase(); // case-insensitive comparison
|
||||
lang.toUpperCase();
|
||||
result = lang.indexOf(arg) == 0 &&
|
||||
(lang.length() == arg.length() ||
|
||||
lang.charAt(arg.length()) == '-');
|
||||
(lang.Length() == arg.Length() ||
|
||||
lang.CharAt(arg.Length()) == '-');
|
||||
}
|
||||
|
||||
return new BooleanResult(result);
|
||||
|
@ -93,7 +93,7 @@ ExprResult* BooleanFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case TX_NOT:
|
||||
{
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
return new BooleanResult(!evaluateToBoolean((Expr*)iter.next(),
|
||||
aContext));
|
||||
|
@ -101,22 +101,22 @@ ExprResult* BooleanFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case TX_TRUE:
|
||||
{
|
||||
if (!requireParams(0, 0, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
return new BooleanResult(MB_TRUE);
|
||||
}
|
||||
case TX_FALSE:
|
||||
{
|
||||
if (!requireParams(0, 0, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
return new BooleanResult(MB_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
String err("Internal error");
|
||||
String err(NS_LITERAL_STRING("Internal error"));
|
||||
aContext->receiveError(err, NS_ERROR_UNEXPECTED);
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
|
||||
nsresult BooleanFunctionCall::getNameAtom(txAtom** aAtom)
|
||||
|
|
|
@ -58,8 +58,8 @@ short BooleanResult::getResultType() {
|
|||
} //-- getResultType
|
||||
|
||||
void BooleanResult::stringValue(String& str) {
|
||||
if ( value ) str.append("true");
|
||||
else str.append("false");
|
||||
if ( value ) str.Append(NS_LITERAL_STRING("true"));
|
||||
else str.Append(NS_LITERAL_STRING("false"));
|
||||
} //-- toString
|
||||
|
||||
MBool BooleanResult::booleanValue() {
|
||||
|
|
|
@ -75,10 +75,10 @@ Token::Token(const String& value, short type)
|
|||
this->value = value;
|
||||
} //-- Token
|
||||
|
||||
Token::Token(UNICODE_CHAR uniChar, short type)
|
||||
Token::Token(PRUnichar uniChar, short type)
|
||||
{
|
||||
this->type = type;
|
||||
this->value.append(uniChar);
|
||||
this->value.Append(uniChar);
|
||||
} //-- Token
|
||||
|
||||
/**
|
||||
|
@ -107,30 +107,30 @@ Token::~Token()
|
|||
* Complex Tokens
|
||||
*/
|
||||
//-- Nodetype tokens
|
||||
const String ExprLexer::COMMENT("comment");
|
||||
const String ExprLexer::NODE("node");
|
||||
const String ExprLexer::PROC_INST("processing-instruction");
|
||||
const String ExprLexer::TEXT("text");
|
||||
const String ExprLexer::COMMENT(NS_LITERAL_STRING("comment"));
|
||||
const String ExprLexer::NODE(NS_LITERAL_STRING("node"));
|
||||
const String ExprLexer::PROC_INST(NS_LITERAL_STRING("processing-instruction"));
|
||||
const String ExprLexer::TEXT(NS_LITERAL_STRING("text"));
|
||||
|
||||
//-- boolean
|
||||
const String ExprLexer::AND("and");
|
||||
const String ExprLexer::OR("or");
|
||||
const String ExprLexer::AND(NS_LITERAL_STRING("and"));
|
||||
const String ExprLexer::OR(NS_LITERAL_STRING("or"));
|
||||
|
||||
//-- multiplicative operators
|
||||
const String ExprLexer::MODULUS("mod");
|
||||
const String ExprLexer::DIVIDE("div");
|
||||
const String ExprLexer::MODULUS(NS_LITERAL_STRING("mod"));
|
||||
const String ExprLexer::DIVIDE(NS_LITERAL_STRING("div"));
|
||||
|
||||
/**
|
||||
* The set of Lexer error messages
|
||||
**/
|
||||
const String ExprLexer::error_message[] =
|
||||
{
|
||||
String("VariableReference expected"),
|
||||
String("Operator expected"),
|
||||
String("Literal is not closed"),
|
||||
String(": not expected"),
|
||||
String("! not expected, use != or not()"),
|
||||
String("found a unkown character")
|
||||
String(NS_LITERAL_STRING("VariableReference expected")),
|
||||
String(NS_LITERAL_STRING("Operator expected")),
|
||||
String(NS_LITERAL_STRING("Literal is not closed")),
|
||||
String(NS_LITERAL_STRING(": not expected")),
|
||||
String(NS_LITERAL_STRING("! not expected, use != or not()")),
|
||||
String(NS_LITERAL_STRING("found a unkown character"))
|
||||
};
|
||||
|
||||
//---------------/
|
||||
|
@ -234,14 +234,14 @@ MBool ExprLexer::nextIsOperatorToken(Token* token)
|
|||
**/
|
||||
void ExprLexer::parse(const String& pattern)
|
||||
{
|
||||
if (pattern.isEmpty())
|
||||
if (pattern.IsEmpty())
|
||||
return;
|
||||
|
||||
String tokenBuffer;
|
||||
PRUint32 iter = 0, start;
|
||||
PRUint32 size = pattern.length();
|
||||
PRUint32 size = pattern.Length();
|
||||
short defType;
|
||||
UNICODE_CHAR ch;
|
||||
PRUnichar ch;
|
||||
|
||||
//-- initialize previous token, this will automatically get
|
||||
//-- deleted when it goes out of scope
|
||||
|
@ -251,11 +251,11 @@ void ExprLexer::parse(const String& pattern)
|
|||
|
||||
while (iter < size) {
|
||||
|
||||
ch = pattern.charAt(iter);
|
||||
ch = pattern.CharAt(iter);
|
||||
defType = Token::CNAME;
|
||||
|
||||
if (ch==DOLLAR_SIGN) {
|
||||
if (++iter == size || !XMLUtils::isLetter(ch=pattern.charAt(iter))) {
|
||||
if (++iter == size || !XMLUtils::isLetter(ch=pattern.CharAt(iter))) {
|
||||
// Error, VariableReference expected
|
||||
errorPos = iter;
|
||||
errorCode = ERROR_UNRESOLVED_VAR_REFERENCE;
|
||||
|
@ -277,27 +277,27 @@ void ExprLexer::parse(const String& pattern)
|
|||
// and are dealt with below
|
||||
start = iter;
|
||||
while (++iter < size &&
|
||||
XMLUtils::isNCNameChar(pattern.charAt(iter))) /* just go */ ;
|
||||
if (iter < size && pattern.charAt(iter)==COLON) {
|
||||
XMLUtils::isNCNameChar(pattern.CharAt(iter))) /* just go */ ;
|
||||
if (iter < size && pattern.CharAt(iter)==COLON) {
|
||||
// try QName or wildcard, might need to step back for axis
|
||||
if (++iter < size)
|
||||
if (XMLUtils::isLetter(pattern.charAt(iter)))
|
||||
if (XMLUtils::isLetter(pattern.CharAt(iter)))
|
||||
while (++iter < size &&
|
||||
XMLUtils::isNCNameChar(pattern.charAt(iter))) /* just go */ ;
|
||||
else if (pattern.charAt(iter)=='*'
|
||||
XMLUtils::isNCNameChar(pattern.CharAt(iter))) /* just go */ ;
|
||||
else if (pattern.CharAt(iter)=='*'
|
||||
&& defType != Token::VAR_REFERENCE)
|
||||
++iter; /* eat wildcard for NameTest, bail for var ref at COLON */
|
||||
else
|
||||
iter--; // step back
|
||||
}
|
||||
if (nextIsOperatorToken(prevToken)) {
|
||||
if (pattern.subString(start,iter,subStr).isEqual(AND))
|
||||
if (pattern.subString(start,iter,subStr).Equals(AND))
|
||||
defType = Token::AND_OP;
|
||||
else if (pattern.subString(start,iter,subStr).isEqual(OR))
|
||||
else if (pattern.subString(start,iter,subStr).Equals(OR))
|
||||
defType = Token::OR_OP;
|
||||
else if (pattern.subString(start,iter,subStr).isEqual(MODULUS))
|
||||
else if (pattern.subString(start,iter,subStr).Equals(MODULUS))
|
||||
defType = Token::MODULUS_OP;
|
||||
else if (pattern.subString(start,iter,subStr).isEqual(DIVIDE))
|
||||
else if (pattern.subString(start,iter,subStr).Equals(DIVIDE))
|
||||
defType = Token::DIVIDE_OP;
|
||||
else {
|
||||
// Error "operator expected"
|
||||
|
@ -317,10 +317,10 @@ void ExprLexer::parse(const String& pattern)
|
|||
else if (isXPathDigit(ch)) {
|
||||
start = iter;
|
||||
while (++iter < size &&
|
||||
isXPathDigit(pattern.charAt(iter))) /* just go */;
|
||||
if (iter < size && pattern.charAt(iter) == '.')
|
||||
isXPathDigit(pattern.CharAt(iter))) /* just go */;
|
||||
if (iter < size && pattern.CharAt(iter) == '.')
|
||||
while (++iter < size &&
|
||||
isXPathDigit(pattern.charAt(iter))) /* just go */;
|
||||
isXPathDigit(pattern.CharAt(iter))) /* just go */;
|
||||
addToken(new Token(pattern.subString(start,iter,subStr),Token::NUMBER));
|
||||
}
|
||||
else {
|
||||
|
@ -355,11 +355,11 @@ void ExprLexer::parse(const String& pattern)
|
|||
case PERIOD:
|
||||
// period can be .., .(DIGITS)+ or ., check next
|
||||
if (++iter < size) {
|
||||
ch=pattern.charAt(iter);
|
||||
ch=pattern.CharAt(iter);
|
||||
if (isXPathDigit(ch)) {
|
||||
start=iter-1;
|
||||
while (++iter < size &&
|
||||
isXPathDigit(pattern.charAt(iter))) /* just go */;
|
||||
isXPathDigit(pattern.CharAt(iter))) /* just go */;
|
||||
addToken(new Token(pattern.subString(start,iter,subStr),
|
||||
Token::NUMBER));
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ void ExprLexer::parse(const String& pattern)
|
|||
|
||||
break;
|
||||
case COLON: // QNames are dealt above, must be axis ident
|
||||
if (++iter < size && pattern.charAt(iter)==COLON &&
|
||||
if (++iter < size && pattern.CharAt(iter)==COLON &&
|
||||
prevToken->type == Token::CNAME) {
|
||||
prevToken->type = Token::AXIS_IDENTIFIER;
|
||||
++iter;
|
||||
|
@ -393,7 +393,7 @@ void ExprLexer::parse(const String& pattern)
|
|||
}
|
||||
break;
|
||||
case FORWARD_SLASH :
|
||||
if (++iter < size && pattern.charAt(iter)==ch) {
|
||||
if (++iter < size && pattern.CharAt(iter)==ch) {
|
||||
addToken(new Token(pattern.subString(iter-1,++iter,subStr),
|
||||
Token::ANCESTOR_OP));
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ void ExprLexer::parse(const String& pattern)
|
|||
}
|
||||
break;
|
||||
case BANG : // can only be !=
|
||||
if (++iter < size && pattern.charAt(iter)==EQUAL) {
|
||||
if (++iter < size && pattern.CharAt(iter)==EQUAL) {
|
||||
addToken(new Token(pattern.subString(iter-1,++iter,subStr),
|
||||
Token::NOT_EQUAL_OP));
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ void ExprLexer::parse(const String& pattern)
|
|||
++iter;
|
||||
break;
|
||||
case L_ANGLE:
|
||||
if (++iter < size && pattern.charAt(iter)==EQUAL) {
|
||||
if (++iter < size && pattern.CharAt(iter)==EQUAL) {
|
||||
addToken(new Token(pattern.subString(iter-1,++iter,subStr),
|
||||
Token::LESS_OR_EQUAL_OP));
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ void ExprLexer::parse(const String& pattern)
|
|||
addToken(new Token(ch,Token::LESS_THAN_OP));
|
||||
break;
|
||||
case R_ANGLE:
|
||||
if (++iter < size && pattern.charAt(iter)==EQUAL) {
|
||||
if (++iter < size && pattern.CharAt(iter)==EQUAL) {
|
||||
addToken(new Token(pattern.subString(iter-1,++iter,subStr),
|
||||
Token::GREATER_OR_EQUAL_OP));
|
||||
}
|
||||
|
@ -450,13 +450,13 @@ void ExprLexer::parse(const String& pattern)
|
|||
break;
|
||||
case L_PAREN:
|
||||
if (prevToken->type == Token::CNAME) {
|
||||
if (prevToken->value.isEqual(COMMENT))
|
||||
if (prevToken->value.Equals(COMMENT))
|
||||
prevToken->type = Token::COMMENT;
|
||||
else if (prevToken->value.isEqual(NODE))
|
||||
else if (prevToken->value.Equals(NODE))
|
||||
prevToken->type = Token::NODE;
|
||||
else if (prevToken->value.isEqual(PROC_INST))
|
||||
else if (prevToken->value.Equals(PROC_INST))
|
||||
prevToken->type = Token::PROC_INST;
|
||||
else if (prevToken->value.isEqual(TEXT))
|
||||
else if (prevToken->value.Equals(TEXT))
|
||||
prevToken->type = Token::TEXT;
|
||||
else
|
||||
prevToken->type = Token::FUNCTION_NAME;
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
Token();
|
||||
Token(short type);
|
||||
Token(const String& value, short type);
|
||||
Token(UNICODE_CHAR uniChar, short type);
|
||||
Token(PRUnichar uniChar, short type);
|
||||
/**
|
||||
* Copy Constructor
|
||||
**/
|
||||
|
@ -254,7 +254,7 @@ private:
|
|||
* Returns true if the given character represents a numeric letter (digit)
|
||||
* Implemented in ExprLexerChars.cpp
|
||||
**/
|
||||
static MBool isXPathDigit(UNICODE_CHAR ch)
|
||||
static MBool isXPathDigit(PRUnichar ch)
|
||||
{
|
||||
return (ch >= '0' && ch <= '9');
|
||||
}
|
||||
|
|
|
@ -80,33 +80,33 @@ public:
|
|||
static const String FLOOR_FN;
|
||||
};
|
||||
|
||||
const String XPathNames::BOOLEAN_FN("boolean");
|
||||
const String XPathNames::CONCAT_FN("concat");
|
||||
const String XPathNames::CONTAINS_FN("contains");
|
||||
const String XPathNames::COUNT_FN("count");
|
||||
const String XPathNames::FALSE_FN("false");
|
||||
const String XPathNames::ID_FN("id");
|
||||
const String XPathNames::LAST_FN("last");
|
||||
const String XPathNames::LOCAL_NAME_FN("local-name");
|
||||
const String XPathNames::NAME_FN("name");
|
||||
const String XPathNames::NAMESPACE_URI_FN("namespace-uri");
|
||||
const String XPathNames::NORMALIZE_SPACE_FN("normalize-space");
|
||||
const String XPathNames::NOT_FN("not");
|
||||
const String XPathNames::POSITION_FN("position");
|
||||
const String XPathNames::STARTS_WITH_FN("starts-with");
|
||||
const String XPathNames::STRING_FN("string");
|
||||
const String XPathNames::STRING_LENGTH_FN("string-length");
|
||||
const String XPathNames::SUBSTRING_FN("substring");
|
||||
const String XPathNames::SUBSTRING_AFTER_FN("substring-after");
|
||||
const String XPathNames::SUBSTRING_BEFORE_FN("substring-before");
|
||||
const String XPathNames::SUM_FN("sum");
|
||||
const String XPathNames::TRANSLATE_FN("translate");
|
||||
const String XPathNames::TRUE_FN("true");
|
||||
const String XPathNames::NUMBER_FN("number");
|
||||
const String XPathNames::ROUND_FN("round");
|
||||
const String XPathNames::CEILING_FN("ceiling");
|
||||
const String XPathNames::FLOOR_FN("floor");
|
||||
const String XPathNames::LANG_FN("lang");
|
||||
const String XPathNames::BOOLEAN_FN(NS_LITERAL_STRING("boolean"));
|
||||
const String XPathNames::CONCAT_FN(NS_LITERAL_STRING("concat"));
|
||||
const String XPathNames::CONTAINS_FN(NS_LITERAL_STRING("contains"));
|
||||
const String XPathNames::COUNT_FN(NS_LITERAL_STRING("count"));
|
||||
const String XPathNames::FALSE_FN(NS_LITERAL_STRING("false"));
|
||||
const String XPathNames::ID_FN(NS_LITERAL_STRING("id"));
|
||||
const String XPathNames::LAST_FN(NS_LITERAL_STRING("last"));
|
||||
const String XPathNames::LOCAL_NAME_FN(NS_LITERAL_STRING("local-name"));
|
||||
const String XPathNames::NAME_FN(NS_LITERAL_STRING("name"));
|
||||
const String XPathNames::NAMESPACE_URI_FN(NS_LITERAL_STRING("namespace-uri"));
|
||||
const String XPathNames::NORMALIZE_SPACE_FN(NS_LITERAL_STRING("normalize-space"));
|
||||
const String XPathNames::NOT_FN(NS_LITERAL_STRING("not"));
|
||||
const String XPathNames::POSITION_FN(NS_LITERAL_STRING("position"));
|
||||
const String XPathNames::STARTS_WITH_FN(NS_LITERAL_STRING("starts-with"));
|
||||
const String XPathNames::STRING_FN(NS_LITERAL_STRING("string"));
|
||||
const String XPathNames::STRING_LENGTH_FN(NS_LITERAL_STRING("string-length"));
|
||||
const String XPathNames::SUBSTRING_FN(NS_LITERAL_STRING("substring"));
|
||||
const String XPathNames::SUBSTRING_AFTER_FN(NS_LITERAL_STRING("substring-after"));
|
||||
const String XPathNames::SUBSTRING_BEFORE_FN(NS_LITERAL_STRING("substring-before"));
|
||||
const String XPathNames::SUM_FN(NS_LITERAL_STRING("sum"));
|
||||
const String XPathNames::TRANSLATE_FN(NS_LITERAL_STRING("translate"));
|
||||
const String XPathNames::TRUE_FN(NS_LITERAL_STRING("true"));
|
||||
const String XPathNames::NUMBER_FN(NS_LITERAL_STRING("number"));
|
||||
const String XPathNames::ROUND_FN(NS_LITERAL_STRING("round"));
|
||||
const String XPathNames::CEILING_FN(NS_LITERAL_STRING("ceiling"));
|
||||
const String XPathNames::FLOOR_FN(NS_LITERAL_STRING("floor"));
|
||||
const String XPathNames::LANG_FN(NS_LITERAL_STRING("lang"));
|
||||
|
||||
|
||||
/**
|
||||
|
@ -122,32 +122,32 @@ AttributeValueTemplate* ExprParser::createAttributeValueTemplate
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (attValue.isEmpty())
|
||||
if (attValue.IsEmpty())
|
||||
return avt;
|
||||
|
||||
PRUint32 size = attValue.length();
|
||||
PRUint32 size = attValue.Length();
|
||||
PRUint32 cc = 0;
|
||||
UNICODE_CHAR nextCh;
|
||||
UNICODE_CHAR ch;
|
||||
PRUnichar nextCh;
|
||||
PRUnichar ch;
|
||||
String buffer;
|
||||
MBool inExpr = MB_FALSE;
|
||||
MBool inLiteral = MB_FALSE;
|
||||
UNICODE_CHAR endLiteral = 0;
|
||||
PRUnichar endLiteral = 0;
|
||||
|
||||
nextCh = attValue.charAt(cc);
|
||||
nextCh = attValue.CharAt(cc);
|
||||
while (cc++ < size) {
|
||||
ch = nextCh;
|
||||
nextCh = cc != size ? attValue.charAt(cc) : 0;
|
||||
nextCh = cc != size ? attValue.CharAt(cc) : 0;
|
||||
|
||||
// if in literal just add ch to buffer
|
||||
if (inLiteral && (ch != endLiteral)) {
|
||||
buffer.append(ch);
|
||||
buffer.Append(ch);
|
||||
continue;
|
||||
}
|
||||
switch ( ch ) {
|
||||
case '\'' :
|
||||
case '"' :
|
||||
buffer.append(ch);
|
||||
buffer.Append(ch);
|
||||
if (inLiteral)
|
||||
inLiteral = MB_FALSE;
|
||||
else if (inExpr) {
|
||||
|
@ -159,12 +159,12 @@ AttributeValueTemplate* ExprParser::createAttributeValueTemplate
|
|||
if (!inExpr) {
|
||||
// Ignore case where we find two {
|
||||
if (nextCh == ch) {
|
||||
buffer.append(ch); //-- append '{'
|
||||
buffer.Append(ch); //-- append '{'
|
||||
cc++;
|
||||
nextCh = cc != size ? attValue.charAt(cc) : 0;
|
||||
nextCh = cc != size ? attValue.CharAt(cc) : 0;
|
||||
}
|
||||
else {
|
||||
if (!buffer.isEmpty()) {
|
||||
if (!buffer.IsEmpty()) {
|
||||
Expr* strExpr = new StringExpr(buffer);
|
||||
if (!strExpr) {
|
||||
// XXX ErrorReport: out of memory
|
||||
|
@ -173,12 +173,12 @@ AttributeValueTemplate* ExprParser::createAttributeValueTemplate
|
|||
}
|
||||
avt->addExpr(strExpr);
|
||||
}
|
||||
buffer.clear();
|
||||
buffer.Truncate();
|
||||
inExpr = MB_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
buffer.append(ch); //-- simply append '{'
|
||||
buffer.Append(ch); //-- simply append '{'
|
||||
break;
|
||||
case '}':
|
||||
if (inExpr) {
|
||||
|
@ -190,12 +190,12 @@ AttributeValueTemplate* ExprParser::createAttributeValueTemplate
|
|||
return 0;
|
||||
}
|
||||
avt->addExpr(expr);
|
||||
buffer.clear();
|
||||
buffer.Truncate();
|
||||
}
|
||||
else if (nextCh == ch) {
|
||||
buffer.append(ch);
|
||||
buffer.Append(ch);
|
||||
cc++;
|
||||
nextCh = cc != size ? attValue.charAt(cc) : 0;
|
||||
nextCh = cc != size ? attValue.CharAt(cc) : 0;
|
||||
}
|
||||
else {
|
||||
//XXX ErrorReport: unmatched '}' found
|
||||
|
@ -204,7 +204,7 @@ AttributeValueTemplate* ExprParser::createAttributeValueTemplate
|
|||
}
|
||||
break;
|
||||
default:
|
||||
buffer.append(ch);
|
||||
buffer.Append(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ AttributeValueTemplate* ExprParser::createAttributeValueTemplate
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!buffer.isEmpty()) {
|
||||
if (!buffer.IsEmpty()) {
|
||||
Expr* strExpr = new StringExpr(buffer);
|
||||
if (!strExpr) {
|
||||
// XXX ErrorReport: out of memory
|
||||
|
@ -470,85 +470,85 @@ Expr* ExprParser::createFunctionCall(ExprLexer& lexer,
|
|||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (XPathNames::BOOLEAN_FN.isEqual(tok->value)) {
|
||||
if (XPathNames::BOOLEAN_FN.Equals(tok->value)) {
|
||||
fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_BOOLEAN);
|
||||
}
|
||||
else if (XPathNames::CONCAT_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::CONCAT_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::CONCAT);
|
||||
}
|
||||
else if (XPathNames::CONTAINS_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::CONTAINS_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::CONTAINS);
|
||||
}
|
||||
else if (XPathNames::COUNT_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::COUNT_FN.Equals(tok->value)) {
|
||||
fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::COUNT);
|
||||
}
|
||||
else if (XPathNames::FALSE_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::FALSE_FN.Equals(tok->value)) {
|
||||
fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_FALSE);
|
||||
}
|
||||
else if (XPathNames::ID_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::ID_FN.Equals(tok->value)) {
|
||||
fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::ID);
|
||||
}
|
||||
else if (XPathNames::LANG_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::LANG_FN.Equals(tok->value)) {
|
||||
fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_LANG);
|
||||
}
|
||||
else if (XPathNames::LAST_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::LAST_FN.Equals(tok->value)) {
|
||||
fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::LAST);
|
||||
}
|
||||
else if (XPathNames::LOCAL_NAME_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::LOCAL_NAME_FN.Equals(tok->value)) {
|
||||
fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::LOCAL_NAME);
|
||||
}
|
||||
else if (XPathNames::NAME_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::NAME_FN.Equals(tok->value)) {
|
||||
fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::NAME);
|
||||
}
|
||||
else if (XPathNames::NAMESPACE_URI_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::NAMESPACE_URI_FN.Equals(tok->value)) {
|
||||
fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::NAMESPACE_URI);
|
||||
}
|
||||
else if (XPathNames::NORMALIZE_SPACE_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::NORMALIZE_SPACE_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::NORMALIZE_SPACE);
|
||||
}
|
||||
else if (XPathNames::NOT_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::NOT_FN.Equals(tok->value)) {
|
||||
fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_NOT);
|
||||
}
|
||||
else if (XPathNames::POSITION_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::POSITION_FN.Equals(tok->value)) {
|
||||
fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::POSITION);
|
||||
}
|
||||
else if (XPathNames::STARTS_WITH_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::STARTS_WITH_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::STARTS_WITH);
|
||||
}
|
||||
else if (XPathNames::STRING_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::STRING_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::STRING);
|
||||
}
|
||||
else if (XPathNames::STRING_LENGTH_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::STRING_LENGTH_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::STRING_LENGTH);
|
||||
}
|
||||
else if (XPathNames::SUBSTRING_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::SUBSTRING_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::SUBSTRING);
|
||||
}
|
||||
else if (XPathNames::SUBSTRING_AFTER_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::SUBSTRING_AFTER_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::SUBSTRING_AFTER);
|
||||
}
|
||||
else if (XPathNames::SUBSTRING_BEFORE_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::SUBSTRING_BEFORE_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::SUBSTRING_BEFORE);
|
||||
}
|
||||
else if (XPathNames::SUM_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::SUM_FN.Equals(tok->value)) {
|
||||
fnCall = new NumberFunctionCall(NumberFunctionCall::SUM);
|
||||
}
|
||||
else if (XPathNames::TRANSLATE_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::TRANSLATE_FN.Equals(tok->value)) {
|
||||
fnCall = new StringFunctionCall(StringFunctionCall::TRANSLATE);
|
||||
}
|
||||
else if (XPathNames::TRUE_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::TRUE_FN.Equals(tok->value)) {
|
||||
fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_TRUE);
|
||||
}
|
||||
else if (XPathNames::NUMBER_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::NUMBER_FN.Equals(tok->value)) {
|
||||
fnCall = new NumberFunctionCall(NumberFunctionCall::NUMBER);
|
||||
}
|
||||
else if (XPathNames::ROUND_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::ROUND_FN.Equals(tok->value)) {
|
||||
fnCall = new NumberFunctionCall(NumberFunctionCall::ROUND);
|
||||
}
|
||||
else if (XPathNames::CEILING_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::CEILING_FN.Equals(tok->value)) {
|
||||
fnCall = new NumberFunctionCall(NumberFunctionCall::CEILING);
|
||||
}
|
||||
else if (XPathNames::FLOOR_FN.isEqual(tok->value)) {
|
||||
else if (XPathNames::FLOOR_FN.Equals(tok->value)) {
|
||||
fnCall = new NumberFunctionCall(NumberFunctionCall::FLOOR);
|
||||
}
|
||||
else {
|
||||
|
@ -573,7 +573,7 @@ Expr* ExprParser::createFunctionCall(ExprLexer& lexer,
|
|||
return 0;
|
||||
}
|
||||
String err(tok->value);
|
||||
err.append(" not implemented.");
|
||||
err.Append(NS_LITERAL_STRING(" not implemented."));
|
||||
return new StringExpr(err);
|
||||
}
|
||||
|
||||
|
@ -612,43 +612,43 @@ LocationStep* ExprParser::createLocationStep(ExprLexer& lexer,
|
|||
//-- eat token
|
||||
lexer.nextToken();
|
||||
//-- should switch to a hash here for speed if necessary
|
||||
if (ANCESTOR_AXIS.isEqual(tok->value)) {
|
||||
if (ANCESTOR_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::ANCESTOR_AXIS;
|
||||
}
|
||||
else if (ANCESTOR_OR_SELF_AXIS.isEqual(tok->value)) {
|
||||
else if (ANCESTOR_OR_SELF_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::ANCESTOR_OR_SELF_AXIS;
|
||||
}
|
||||
else if (ATTRIBUTE_AXIS.isEqual(tok->value)) {
|
||||
else if (ATTRIBUTE_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::ATTRIBUTE_AXIS;
|
||||
}
|
||||
else if (CHILD_AXIS.isEqual(tok->value)) {
|
||||
else if (CHILD_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::CHILD_AXIS;
|
||||
}
|
||||
else if (DESCENDANT_AXIS.isEqual(tok->value)) {
|
||||
else if (DESCENDANT_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::DESCENDANT_AXIS;
|
||||
}
|
||||
else if (DESCENDANT_OR_SELF_AXIS.isEqual(tok->value)) {
|
||||
else if (DESCENDANT_OR_SELF_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::DESCENDANT_OR_SELF_AXIS;
|
||||
}
|
||||
else if (FOLLOWING_AXIS.isEqual(tok->value)) {
|
||||
else if (FOLLOWING_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::FOLLOWING_AXIS;
|
||||
}
|
||||
else if (FOLLOWING_SIBLING_AXIS.isEqual(tok->value)) {
|
||||
else if (FOLLOWING_SIBLING_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::FOLLOWING_SIBLING_AXIS;
|
||||
}
|
||||
else if (NAMESPACE_AXIS.isEqual(tok->value)) {
|
||||
else if (NAMESPACE_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::NAMESPACE_AXIS;
|
||||
}
|
||||
else if (PARENT_AXIS.isEqual(tok->value)) {
|
||||
else if (PARENT_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::PARENT_AXIS;
|
||||
}
|
||||
else if (PRECEDING_AXIS.isEqual(tok->value)) {
|
||||
else if (PRECEDING_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::PRECEDING_AXIS;
|
||||
}
|
||||
else if (PRECEDING_SIBLING_AXIS.isEqual(tok->value)) {
|
||||
else if (PRECEDING_SIBLING_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::PRECEDING_SIBLING_AXIS;
|
||||
}
|
||||
else if (SELF_AXIS.isEqual(tok->value)) {
|
||||
else if (SELF_AXIS.Equals(tok->value)) {
|
||||
axisIdentifier = LocationStep::SELF_AXIS;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -129,8 +129,7 @@ class StringResult : public ExprResult {
|
|||
public:
|
||||
|
||||
StringResult();
|
||||
StringResult(const String& str);
|
||||
StringResult(const char* str);
|
||||
StringResult(const nsAString& str);
|
||||
|
||||
virtual ExprResult* clone();
|
||||
virtual short getResultType();
|
||||
|
|
|
@ -73,7 +73,7 @@ ExprResult* FilterExpr::evaluate(txIEvalContext* aContext)
|
|||
}
|
||||
else if(!isEmpty()) {
|
||||
// We can't filter a non-nodeset
|
||||
String err("Expecting nodeset as result of: ");
|
||||
String err(NS_LITERAL_STRING("Expecting nodeset as result of: "));
|
||||
expr->toString(err);
|
||||
aContext->receiveError(err, NS_ERROR_XPATH_EVAL_FAILED);
|
||||
delete exprResult;
|
||||
|
@ -90,7 +90,7 @@ ExprResult* FilterExpr::evaluate(txIEvalContext* aContext)
|
|||
**/
|
||||
void FilterExpr::toString(String& str) {
|
||||
if ( expr ) expr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
PredicateList::toString(str);
|
||||
} //-- toString
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
**/
|
||||
|
||||
const String FunctionCall::INVALID_PARAM_COUNT(
|
||||
"invalid number of parameters for function: ");
|
||||
NS_LITERAL_STRING("invalid number of parameters for function: "));
|
||||
|
||||
const String FunctionCall::INVALID_PARAM_VALUE(
|
||||
"invalid parameter value for function: ");
|
||||
NS_LITERAL_STRING("invalid parameter value for function: "));
|
||||
|
||||
FunctionCall::FunctionCall()
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ NodeSet* FunctionCall::evaluateToNodeSet(Expr* aExpr, txIEvalContext* aContext)
|
|||
return 0;
|
||||
|
||||
if (exprResult->getResultType() != ExprResult::NODESET) {
|
||||
String err("NodeSet expected as argument");
|
||||
String err(NS_LITERAL_STRING("NodeSet expected as argument"));
|
||||
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
|
||||
delete exprResult;
|
||||
return 0;
|
||||
|
@ -187,17 +187,17 @@ void FunctionCall::toString(String& aDest)
|
|||
}
|
||||
TX_RELEASE_ATOM(functionNameAtom);
|
||||
|
||||
aDest.append(functionName);
|
||||
aDest.append('(');
|
||||
aDest.Append(functionName);
|
||||
aDest.Append(PRUnichar('('));
|
||||
txListIterator iter(¶ms);
|
||||
MBool addComma = MB_FALSE;
|
||||
while (iter.hasNext()) {
|
||||
if (addComma) {
|
||||
aDest.append(',');
|
||||
aDest.Append(PRUnichar(','));
|
||||
}
|
||||
addComma = MB_TRUE;
|
||||
Expr* expr = (Expr*)iter.next();
|
||||
expr->toString(aDest);
|
||||
}
|
||||
aDest.append(')');
|
||||
aDest.Append(PRUnichar(')'));
|
||||
}
|
||||
|
|
|
@ -253,40 +253,40 @@ void LocationStep::fromDescendantsRev(Node* node, txIMatchContext* cs,
|
|||
void LocationStep::toString(String& str) {
|
||||
switch (mAxisIdentifier) {
|
||||
case ANCESTOR_AXIS :
|
||||
str.append("ancestor::");
|
||||
str.Append(NS_LITERAL_STRING("ancestor::"));
|
||||
break;
|
||||
case ANCESTOR_OR_SELF_AXIS :
|
||||
str.append("ancestor-or-self::");
|
||||
str.Append(NS_LITERAL_STRING("ancestor-or-self::"));
|
||||
break;
|
||||
case ATTRIBUTE_AXIS:
|
||||
str.append("@");
|
||||
str.Append(PRUnichar('@'));
|
||||
break;
|
||||
case DESCENDANT_AXIS:
|
||||
str.append("descendant::");
|
||||
str.Append(NS_LITERAL_STRING("descendant::"));
|
||||
break;
|
||||
case DESCENDANT_OR_SELF_AXIS:
|
||||
str.append("descendant-or-self::");
|
||||
str.Append(NS_LITERAL_STRING("descendant-or-self::"));
|
||||
break;
|
||||
case FOLLOWING_AXIS :
|
||||
str.append("following::");
|
||||
str.Append(NS_LITERAL_STRING("following::"));
|
||||
break;
|
||||
case FOLLOWING_SIBLING_AXIS:
|
||||
str.append("following-sibling::");
|
||||
str.Append(NS_LITERAL_STRING("following-sibling::"));
|
||||
break;
|
||||
case NAMESPACE_AXIS:
|
||||
str.append("namespace::");
|
||||
str.Append(NS_LITERAL_STRING("namespace::"));
|
||||
break;
|
||||
case PARENT_AXIS :
|
||||
str.append("parent::");
|
||||
str.Append(NS_LITERAL_STRING("parent::"));
|
||||
break;
|
||||
case PRECEDING_AXIS :
|
||||
str.append("preceding::");
|
||||
str.Append(NS_LITERAL_STRING("preceding::"));
|
||||
break;
|
||||
case PRECEDING_SIBLING_AXIS :
|
||||
str.append("preceding-sibling::");
|
||||
str.Append(NS_LITERAL_STRING("preceding-sibling::"));
|
||||
break;
|
||||
case SELF_AXIS :
|
||||
str.append("self::");
|
||||
str.Append(NS_LITERAL_STRING("self::"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -132,21 +132,21 @@ ExprResult* MultiplicativeExpr::evaluate(txIEvalContext* aContext)
|
|||
void MultiplicativeExpr::toString(String& str) {
|
||||
|
||||
if ( leftExpr ) leftExpr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
|
||||
switch ( op ) {
|
||||
case DIVIDE:
|
||||
str.append(" div ");
|
||||
str.Append(NS_LITERAL_STRING(" div "));
|
||||
break;
|
||||
case MODULUS:
|
||||
str.append(" mod ");
|
||||
str.Append(NS_LITERAL_STRING(" mod "));
|
||||
break;
|
||||
default:
|
||||
str.append(" * ");
|
||||
str.Append(NS_LITERAL_STRING(" * "));
|
||||
break;
|
||||
}
|
||||
if ( rightExpr ) rightExpr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
|
||||
} //-- toString
|
||||
|
||||
|
|
|
@ -60,12 +60,12 @@ ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
|
|||
case COUNT:
|
||||
{
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
NodeSet* nodes;
|
||||
nodes = evaluateToNodeSet((Expr*)iter.next(), aContext);
|
||||
if (!nodes)
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
double count = nodes->size();
|
||||
delete nodes;
|
||||
|
@ -74,12 +74,12 @@ ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
|
|||
case ID:
|
||||
{
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
ExprResult* exprResult;
|
||||
exprResult = ((Expr*)iter.next())->evaluate(aContext);
|
||||
if (!exprResult)
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
NodeSet* resultSet = new NodeSet();
|
||||
if (!resultSet) {
|
||||
|
@ -127,7 +127,7 @@ ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
|
|||
case LAST:
|
||||
{
|
||||
if (!requireParams(0, 0, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
return new NumberResult(aContext->size());
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
|
|||
case NAMESPACE_URI:
|
||||
{
|
||||
if (!requireParams(0, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
Node* node = 0;
|
||||
// Check for optional arg
|
||||
|
@ -144,7 +144,7 @@ ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
|
|||
NodeSet* nodes;
|
||||
nodes = evaluateToNodeSet((Expr*)iter.next(), aContext);
|
||||
if (!nodes)
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
if (nodes->isEmpty()) {
|
||||
delete nodes;
|
||||
|
@ -197,15 +197,15 @@ ExprResult* NodeSetFunctionCall::evaluate(txIEvalContext* aContext) {
|
|||
case POSITION:
|
||||
{
|
||||
if (!requireParams(0, 0, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
return new NumberResult(aContext->position());
|
||||
}
|
||||
}
|
||||
|
||||
String err("Internal error");
|
||||
String err(NS_LITERAL_STRING("Internal error"));
|
||||
aContext->receiveError(err, NS_ERROR_UNEXPECTED);
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
|
||||
nsresult NodeSetFunctionCall::getNameAtom(txAtom** aAtom)
|
||||
|
|
|
@ -61,11 +61,11 @@ ExprResult* NumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
|
||||
if (mType == NUMBER) {
|
||||
if (!requireParams(0, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
else {
|
||||
if (!requireParams(1, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
|
||||
switch (mType) {
|
||||
|
@ -107,7 +107,7 @@ ExprResult* NumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
nodes = evaluateToNodeSet((Expr*)iter.next(), aContext);
|
||||
|
||||
if (!nodes)
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
double res = 0;
|
||||
int i;
|
||||
|
@ -133,9 +133,9 @@ ExprResult* NumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
}
|
||||
}
|
||||
|
||||
String err("Internal error");
|
||||
String err(NS_LITERAL_STRING("Internal error"));
|
||||
aContext->receiveError(err, NS_ERROR_UNEXPECTED);
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
|
||||
nsresult NumberFunctionCall::getNameAtom(txAtom** aAtom)
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
//------------/
|
||||
|
||||
const String PathExpr::RTF_INVALID_OP(
|
||||
"Result tree fragments don't allow location steps");
|
||||
NS_LITERAL_STRING("Result tree fragments don't allow location steps"));
|
||||
const String PathExpr::NODESET_EXPECTED(
|
||||
"Filter expression must evaluate to a NodeSet");
|
||||
NS_LITERAL_STRING("Filter expression must evaluate to a NodeSet"));
|
||||
|
||||
/**
|
||||
* Creates a new PathExpr
|
||||
|
@ -103,7 +103,7 @@ ExprResult* PathExpr::evaluate(txIEvalContext* aContext)
|
|||
{
|
||||
if (!aContext || (expressions.getLength() == 0)) {
|
||||
NS_ASSERTION(0, "internal error");
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
|
||||
NodeSet* nodes = new NodeSet(aContext->getContextNode());
|
||||
|
@ -206,10 +206,10 @@ void PathExpr::toString(String& dest)
|
|||
while ((pxi = (PathExprItem*)iter.next())) {
|
||||
switch (pxi->pathOp) {
|
||||
case DESCENDANT_OP:
|
||||
dest.append("//");
|
||||
dest.Append(NS_LITERAL_STRING("//"));
|
||||
break;
|
||||
case RELATIVE_OP:
|
||||
dest.append('/');
|
||||
dest.Append(PRUnichar('/'));
|
||||
break;
|
||||
}
|
||||
pxi->expr->toString(dest);
|
||||
|
|
|
@ -112,9 +112,9 @@ void PredicateList::toString(String& dest)
|
|||
txListIterator iter(&predicates);
|
||||
while (iter.hasNext()) {
|
||||
Expr* expr = (Expr*) iter.next();
|
||||
dest.append("[");
|
||||
dest.Append(PRUnichar('['));
|
||||
expr->toString(dest);
|
||||
dest.append("]");
|
||||
dest.Append(PRUnichar(']'));
|
||||
}
|
||||
} // toString
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ MBool RelationalExpr::compareResults(ExprResult* left, ExprResult* right) {
|
|||
left->stringValue(lStr);
|
||||
String rStr;
|
||||
right->stringValue(rStr);
|
||||
result = !lStr.isEqual(rStr);
|
||||
result = !lStr.Equals(rStr);
|
||||
}
|
||||
}
|
||||
else if ( op == EQUAL) {
|
||||
|
@ -145,7 +145,7 @@ MBool RelationalExpr::compareResults(ExprResult* left, ExprResult* right) {
|
|||
left->stringValue(lStr);
|
||||
String rStr;
|
||||
right->stringValue(rStr);
|
||||
result = lStr.isEqual(rStr);
|
||||
result = lStr.Equals(rStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -240,31 +240,31 @@ ExprResult* RelationalExpr::evaluate(txIEvalContext* aContext)
|
|||
void RelationalExpr::toString(String& str) {
|
||||
|
||||
if ( leftExpr ) leftExpr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
|
||||
switch ( op ) {
|
||||
case NOT_EQUAL:
|
||||
str.append("!=");
|
||||
str.Append(NS_LITERAL_STRING("!="));
|
||||
break;
|
||||
case LESS_THAN:
|
||||
str.append("<");
|
||||
str.Append(PRUnichar('<'));
|
||||
break;
|
||||
case LESS_OR_EQUAL:
|
||||
str.append("<=");
|
||||
str.Append(NS_LITERAL_STRING("<="));
|
||||
break;
|
||||
case GREATER_THAN :
|
||||
str.append(">");
|
||||
str.Append(PRUnichar('>'));
|
||||
break;
|
||||
case GREATER_OR_EQUAL:
|
||||
str.append(">=");
|
||||
str.Append(NS_LITERAL_STRING(">="));
|
||||
break;
|
||||
default:
|
||||
str.append("=");
|
||||
str.Append(PRUnichar('='));
|
||||
break;
|
||||
}
|
||||
|
||||
if ( rightExpr ) rightExpr->toString(str);
|
||||
else str.append("null");
|
||||
else str.Append(NS_LITERAL_STRING("null"));
|
||||
|
||||
} //-- toString
|
||||
|
||||
|
|
|
@ -65,5 +65,5 @@ ExprResult* RootExpr::evaluate(txIEvalContext* aContext)
|
|||
**/
|
||||
void RootExpr::toString(String& dest) {
|
||||
if (mSerialize)
|
||||
dest.append('/');
|
||||
dest.Append(PRUnichar('/'));
|
||||
} //-- toString
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
**/
|
||||
StringExpr::StringExpr(const String& value) {
|
||||
//-- copy value
|
||||
this->value.append(value);
|
||||
this->value.Append(value);
|
||||
} //-- StringExpr
|
||||
|
||||
/**
|
||||
|
@ -59,11 +59,11 @@ ExprResult* StringExpr::evaluate(txIEvalContext* aContext)
|
|||
* @return the String representation of this Expr.
|
||||
**/
|
||||
void StringExpr::toString(String& str) {
|
||||
UNICODE_CHAR ch = '\'';
|
||||
PRUnichar ch = '\'';
|
||||
if (value.indexOf(ch) != kNotFound)
|
||||
ch = '\"';
|
||||
str.append(ch);
|
||||
str.append(value);
|
||||
str.append(ch);
|
||||
str.Append(ch);
|
||||
str.Append(value);
|
||||
str.Append(ch);
|
||||
} //-- toString
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case CONCAT:
|
||||
{
|
||||
if (!requireParams(2, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String resultStr;
|
||||
while (iter.hasNext()) {
|
||||
|
@ -69,7 +69,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case CONTAINS:
|
||||
{
|
||||
if (!requireParams(2, 2, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String arg1, arg2;
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg1);
|
||||
|
@ -79,7 +79,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case NORMALIZE_SPACE:
|
||||
{
|
||||
if (!requireParams(0, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String resultStr;
|
||||
if (iter.hasNext())
|
||||
|
@ -90,19 +90,20 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
|
||||
MBool addSpace = MB_FALSE;
|
||||
MBool first = MB_TRUE;
|
||||
String normed(resultStr.length());
|
||||
UNICODE_CHAR c;
|
||||
String normed;
|
||||
normed.getNSString().SetCapacity(resultStr.Length());
|
||||
PRUnichar c;
|
||||
PRUint32 src;
|
||||
for (src = 0; src < resultStr.length(); src++) {
|
||||
c = resultStr.charAt(src);
|
||||
for (src = 0; src < resultStr.Length(); src++) {
|
||||
c = resultStr.CharAt(src);
|
||||
if (XMLUtils::isWhitespace(c)) {
|
||||
addSpace = MB_TRUE;
|
||||
}
|
||||
else {
|
||||
if (addSpace && !first)
|
||||
normed.append(' ');
|
||||
normed.Append(PRUnichar(' '));
|
||||
|
||||
normed.append(c);
|
||||
normed.Append(c);
|
||||
addSpace = MB_FALSE;
|
||||
first = MB_FALSE;
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case STARTS_WITH:
|
||||
{
|
||||
if (!requireParams(2, 2, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String arg1, arg2;
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg1);
|
||||
|
@ -122,7 +123,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case STRING_LENGTH:
|
||||
{
|
||||
if (!requireParams(0, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String resultStr;
|
||||
if (iter.hasNext())
|
||||
|
@ -130,12 +131,12 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
else
|
||||
XMLDOMUtils::getNodeValue(aContext->getContextNode(),
|
||||
resultStr);
|
||||
return new NumberResult(resultStr.length());
|
||||
return new NumberResult(resultStr.Length());
|
||||
}
|
||||
case SUBSTRING:
|
||||
{
|
||||
if (!requireParams(2, 3, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String src;
|
||||
double start, end;
|
||||
|
@ -145,7 +146,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
// check for NaN or +/-Inf
|
||||
if (Double::isNaN(start) ||
|
||||
Double::isInfinite(start) ||
|
||||
start >= src.length() + 0.5)
|
||||
start >= src.Length() + 0.5)
|
||||
return new StringResult();
|
||||
|
||||
start = floor(start + 0.5) - 1;
|
||||
|
@ -155,13 +156,13 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
if (Double::isNaN(end) || end < 0)
|
||||
return new StringResult();
|
||||
|
||||
if (end > src.length())
|
||||
end = src.length();
|
||||
if (end > src.Length())
|
||||
end = src.Length();
|
||||
else
|
||||
end = floor(end + 0.5);
|
||||
}
|
||||
else {
|
||||
end = src.length();
|
||||
end = src.Length();
|
||||
}
|
||||
|
||||
if (start < 0)
|
||||
|
@ -177,14 +178,14 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case SUBSTRING_AFTER:
|
||||
{
|
||||
if (!requireParams(2, 2, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String arg1, arg2;
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg1);
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg2);
|
||||
PRInt32 idx = arg1.indexOf(arg2);
|
||||
if (idx != kNotFound) {
|
||||
PRUint32 len = arg2.length();
|
||||
PRUint32 len = arg2.Length();
|
||||
arg1.subString(idx + len, arg2);
|
||||
return new StringResult(arg2);
|
||||
}
|
||||
|
@ -193,14 +194,14 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case SUBSTRING_BEFORE:
|
||||
{
|
||||
if (!requireParams(2, 2, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String arg1, arg2;
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg1);
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg2);
|
||||
PRInt32 idx = arg1.indexOf(arg2);
|
||||
if (idx != kNotFound) {
|
||||
arg2.clear();
|
||||
arg2.Truncate();
|
||||
arg1.subString(0, idx, arg2);
|
||||
return new StringResult(arg2);
|
||||
}
|
||||
|
@ -209,26 +210,26 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case TRANSLATE:
|
||||
{
|
||||
if (!requireParams(3, 3, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String src;
|
||||
evaluateToString((Expr*)iter.next(), aContext, src);
|
||||
if (src.isEmpty())
|
||||
if (src.IsEmpty())
|
||||
return new StringResult();
|
||||
|
||||
String oldChars, newChars, dest;
|
||||
evaluateToString((Expr*)iter.next(), aContext, oldChars);
|
||||
evaluateToString((Expr*)iter.next(), aContext, newChars);
|
||||
PRUint32 i;
|
||||
PRInt32 newCharsLength = (PRInt32)newChars.length();
|
||||
for (i = 0; i < src.length(); i++) {
|
||||
PRInt32 idx = oldChars.indexOf(src.charAt(i));
|
||||
PRInt32 newCharsLength = (PRInt32)newChars.Length();
|
||||
for (i = 0; i < src.Length(); i++) {
|
||||
PRInt32 idx = oldChars.indexOf(src.CharAt(i));
|
||||
if (idx != kNotFound) {
|
||||
if (idx < newCharsLength)
|
||||
dest.append(newChars.charAt((PRUint32)idx));
|
||||
dest.Append(newChars.CharAt((PRUint32)idx));
|
||||
}
|
||||
else {
|
||||
dest.append(src.charAt(i));
|
||||
dest.Append(src.CharAt(i));
|
||||
}
|
||||
}
|
||||
return new StringResult(dest);
|
||||
|
@ -236,7 +237,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
case STRING:
|
||||
{
|
||||
if (!requireParams(0, 1, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
String resultStr;
|
||||
if (iter.hasNext())
|
||||
|
@ -248,9 +249,9 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
}
|
||||
}
|
||||
|
||||
String err("Internal error");
|
||||
String err(NS_LITERAL_STRING("Internal error"));
|
||||
aContext->receiveError(err, NS_ERROR_UNEXPECTED);
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
|
||||
nsresult StringFunctionCall::getNameAtom(txAtom** aAtom)
|
||||
|
|
|
@ -40,18 +40,9 @@ StringResult::StringResult() {
|
|||
* Creates a new StringResult with the value of the given String parameter
|
||||
* @param str the String to use for initialization of this StringResult's value
|
||||
**/
|
||||
StringResult::StringResult(const String& str) {
|
||||
StringResult::StringResult(const nsAString& str) {
|
||||
//-- copy str
|
||||
this->value = str;
|
||||
} //-- StringResult
|
||||
|
||||
/**
|
||||
* Creates a new StringResult with the value of the given String parameter
|
||||
* @param str the String to use for initialization of this StringResult's value
|
||||
**/
|
||||
StringResult::StringResult(const char* str) {
|
||||
//-- copy str
|
||||
this->value.append(str);
|
||||
this->value.Append(str);
|
||||
} //-- StringResult
|
||||
|
||||
/*
|
||||
|
@ -68,11 +59,11 @@ short StringResult::getResultType() {
|
|||
} //-- getResultType
|
||||
|
||||
void StringResult::stringValue(String& str) {
|
||||
str.append(this->value);
|
||||
str.Append(this->value);
|
||||
} //-- stringValue
|
||||
|
||||
MBool StringResult::booleanValue() {
|
||||
return !value.isEmpty();
|
||||
return !value.IsEmpty();
|
||||
} //-- booleanValue
|
||||
|
||||
double StringResult::numberValue() {
|
||||
|
|
|
@ -72,6 +72,6 @@ void UnaryExpr::toString(String& str)
|
|||
{
|
||||
if (!expr)
|
||||
return;
|
||||
str.append('-');
|
||||
str.Append(PRUnichar('-'));
|
||||
expr->toString(str);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ ExprResult* UnionExpr::evaluate(txIEvalContext* aContext)
|
|||
exprResult->getResultType() != ExprResult::NODESET) {
|
||||
delete exprResult;
|
||||
delete nodes;
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
nodes->add((NodeSet*)exprResult);
|
||||
delete exprResult;
|
||||
|
@ -108,7 +108,7 @@ void UnionExpr::toString(String& dest) {
|
|||
while (iter.hasNext()) {
|
||||
//-- set operator
|
||||
if (count > 0)
|
||||
dest.append(" | ");
|
||||
dest.Append(NS_LITERAL_STRING(" | "));
|
||||
((Expr*)iter.next())->toString(dest);
|
||||
++count;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ ExprResult* VariableRefExpr::evaluate(txIEvalContext* aContext)
|
|||
nsresult rv = aContext->getVariable(mNamespace, mLocalName, exprResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
// XXX report error, undefined variable
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
}
|
||||
return exprResult->clone();
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ ExprResult* VariableRefExpr::evaluate(txIEvalContext* aContext)
|
|||
**/
|
||||
void VariableRefExpr::toString(String& aDest)
|
||||
{
|
||||
aDest.append('$');
|
||||
aDest.Append(PRUnichar('$'));
|
||||
if (mPrefix) {
|
||||
String prefix;
|
||||
TX_GET_ATOM_STRING(mPrefix, prefix);
|
||||
aDest.append(prefix);
|
||||
aDest.append(':');
|
||||
aDest.Append(prefix);
|
||||
aDest.Append(PRUnichar(':'));
|
||||
}
|
||||
String lname;
|
||||
TX_GET_ATOM_STRING(mLocalName, lname);
|
||||
aDest.append(lname);
|
||||
aDest.Append(lname);
|
||||
} //-- toString
|
||||
|
|
|
@ -73,8 +73,8 @@ void txForwardContext::receiveError(const String& aMsg, nsresult aRes)
|
|||
{
|
||||
NS_ASSERTION(mInner, "mInner is null!!!");
|
||||
#ifdef DEBUG
|
||||
String error("forwarded error: ");
|
||||
error.append(aMsg);
|
||||
String error(NS_LITERAL_STRING("forwarded error: "));
|
||||
error.Append(aMsg);
|
||||
mInner->receiveError(error, aRes);
|
||||
#else
|
||||
mInner->receiveError(aMsg, aRes);
|
||||
|
|
|
@ -97,10 +97,10 @@ void txNameTest::toString(String& aDest)
|
|||
if (mPrefix) {
|
||||
String prefix;
|
||||
TX_GET_ATOM_STRING(mPrefix, prefix);
|
||||
aDest.append(prefix);
|
||||
aDest.append(':');
|
||||
aDest.Append(prefix);
|
||||
aDest.Append(PRUnichar(':'));
|
||||
}
|
||||
String localName;
|
||||
TX_GET_ATOM_STRING(mLocalName, localName);
|
||||
aDest.append(localName);
|
||||
aDest.Append(localName);
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ void txNodeSetContext::receiveError(const String& aMsg, nsresult aRes)
|
|||
{
|
||||
NS_ASSERTION(mInner, "mInner is null!!!");
|
||||
#ifdef DEBUG
|
||||
String error("forwarded error: ");
|
||||
error.append(aMsg);
|
||||
String error(NS_LITERAL_STRING("forwarded error: "));
|
||||
error.Append(aMsg);
|
||||
mInner->receiveError(error, aRes);
|
||||
#else
|
||||
mInner->receiveError(aMsg, aRes);
|
||||
|
|
|
@ -98,24 +98,24 @@ void txNodeTypeTest::toString(String& aDest)
|
|||
{
|
||||
switch (mNodeType) {
|
||||
case COMMENT_TYPE:
|
||||
aDest.append("comment()");
|
||||
aDest.Append(NS_LITERAL_STRING("comment()"));
|
||||
break;
|
||||
case TEXT_TYPE:
|
||||
aDest.append("text()");
|
||||
aDest.Append(NS_LITERAL_STRING("text()"));
|
||||
break;
|
||||
case PI_TYPE:
|
||||
aDest.append("processing-instruction(");
|
||||
aDest.Append(NS_LITERAL_STRING("processing-instruction("));
|
||||
if (mNodeName) {
|
||||
String str;
|
||||
TX_GET_ATOM_STRING(mNodeName, str);
|
||||
aDest.append('\'');
|
||||
aDest.append(str);
|
||||
aDest.append('\'');
|
||||
aDest.Append(PRUnichar('\''));
|
||||
aDest.Append(str);
|
||||
aDest.Append(PRUnichar('\''));
|
||||
}
|
||||
aDest.append(')');
|
||||
aDest.Append(PRUnichar(')'));
|
||||
break;
|
||||
case NODE_TYPE:
|
||||
aDest.append("node()");
|
||||
aDest.Append(NS_LITERAL_STRING("node()"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ public:
|
|||
{
|
||||
NS_ASSERTION(mInner, "mInner is null!!!");
|
||||
#ifdef DEBUG
|
||||
String error("forwarded error: ");
|
||||
error.append(aMsg);
|
||||
String error(NS_LITERAL_STRING("forwarded error: "));
|
||||
error.Append(aMsg);
|
||||
mInner->receiveError(error, aRes);
|
||||
#else
|
||||
mInner->receiveError(aMsg, aRes);
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999, 2000 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Marina Mechtcheriakova, mmarina@mindspring.com
|
||||
* -- Removed the trailing "s" from FOLLOWING_SIBLING_AXIS, and
|
||||
* PRECEDING_SIBLING_AXIS to be compatible with the
|
||||
* W3C XPath 1.0 Recommendation
|
||||
* -- Added lang attr declaration
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* XSL names used throughout the XSLProcessor.
|
||||
* Probably should be wrapped in a Namespace
|
||||
**/
|
||||
#include "Names.h"
|
||||
|
||||
//-- Global Strings
|
||||
const String STYLESHEET_PI("xml-stylesheet");
|
||||
const String STYLESHEET_PI_OLD("xml:stylesheet");
|
||||
const String XSL_MIME_TYPE("text/xsl");
|
||||
|
||||
//-- Attribute Values
|
||||
const String ASCENDING_VALUE("ascending");
|
||||
const String DESCENDING_VALUE("descending");
|
||||
const String LOWER_FIRST_VALUE("lower-first");
|
||||
const String NUMBER_VALUE("number");
|
||||
const String TEXT_VALUE("text");
|
||||
const String UPPER_FIRST_VALUE("upper-first");
|
||||
const String YES_VALUE("yes");
|
||||
|
||||
//-- Stylesheet attributes
|
||||
const String ANCESTOR_AXIS("ancestor");
|
||||
const String ANCESTOR_OR_SELF_AXIS("ancestor-or-self");
|
||||
const String ATTRIBUTE_AXIS("attribute");
|
||||
const String CHILD_AXIS("child");
|
||||
const String DESCENDANT_AXIS("descendant");
|
||||
const String DESCENDANT_OR_SELF_AXIS("descendant-or-self");
|
||||
const String FOLLOWING_AXIS("following");
|
||||
const String FOLLOWING_SIBLING_AXIS("following-sibling");
|
||||
const String NAMESPACE_AXIS("namespace");
|
||||
const String PARENT_AXIS("parent");
|
||||
const String PRECEDING_AXIS("preceding");
|
||||
const String PRECEDING_SIBLING_AXIS("preceding-sibling");
|
||||
const String SELF_AXIS("self");
|
|
@ -128,7 +128,7 @@ void ProcessorState::addAttributeSet(Element* aAttributeSet,
|
|||
aAttributeSet->getAttr(txXSLTAtoms::name, kNameSpaceID_None, nameStr);
|
||||
nsresult rv = name.init(nameStr, aAttributeSet, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("missing or malformed name for xsl:attribute-set");
|
||||
String err(NS_LITERAL_STRING("missing or malformed name for xsl:attribute-set"));
|
||||
receiveError(err);
|
||||
return;
|
||||
}
|
||||
|
@ -181,18 +181,18 @@ void ProcessorState::addTemplate(Element* aXslTemplate,
|
|||
txExpandedName name;
|
||||
rv = name.init(nameStr, aXslTemplate, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("missing or malformed template name: '");
|
||||
err.append(nameStr);
|
||||
err.append('\'');
|
||||
String err(NS_LITERAL_STRING("missing or malformed template name: '"));
|
||||
err.Append(nameStr);
|
||||
err.Append(PRUnichar('\''));
|
||||
receiveError(err, NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
rv = aImportFrame->mNamedTemplates.add(name, aXslTemplate);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("Unable to add template named '");
|
||||
err.append(nameStr);
|
||||
err.append("'. Does that name already exist?");
|
||||
String err(NS_LITERAL_STRING("Unable to add template named '"));
|
||||
err.Append(nameStr);
|
||||
err.Append(NS_LITERAL_STRING("'. Does that name already exist?"));
|
||||
receiveError(err, NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -210,9 +210,9 @@ void ProcessorState::addTemplate(Element* aXslTemplate,
|
|||
if (aXslTemplate->getAttr(txXSLTAtoms::mode, kNameSpaceID_None, modeStr)) {
|
||||
rv = mode.init(modeStr, aXslTemplate, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("malformed template-mode name: '");
|
||||
err.append(modeStr);
|
||||
err.append('\'');
|
||||
String err(NS_LITERAL_STRING("malformed template-mode name: '"));
|
||||
err.Append(modeStr);
|
||||
err.Append(PRUnichar('\''));
|
||||
receiveError(err, NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -376,10 +376,10 @@ Node* ProcessorState::retrieveDocument(const String& uri, const String& baseUri)
|
|||
xmlDoc = xmlParser.getDocumentFromURI(docUrl, xslDocument, errMsg);
|
||||
|
||||
if (!xmlDoc) {
|
||||
String err("Couldn't load document '");
|
||||
err.append(docUrl);
|
||||
err.append("': ");
|
||||
err.append(errMsg);
|
||||
String err(NS_LITERAL_STRING("Couldn't load document '"));
|
||||
err.Append(docUrl);
|
||||
err.Append(NS_LITERAL_STRING("': "));
|
||||
err.Append(errMsg);
|
||||
receiveError(err, NS_ERROR_XSLT_INVALID_URL);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ Node* ProcessorState::retrieveDocument(const String& uri, const String& baseUri)
|
|||
}
|
||||
|
||||
// return element with supplied id if supplied
|
||||
if (!frag.isEmpty())
|
||||
if (!frag.IsEmpty())
|
||||
return xmlDoc->getElementById(frag);
|
||||
|
||||
return xmlDoc;
|
||||
|
@ -575,8 +575,8 @@ Expr* ProcessorState::getExpr(Element* aElem, ExprAttr aAttr)
|
|||
expr = ExprParser::createExpr(attr, &pContext);
|
||||
|
||||
if (!expr) {
|
||||
String err("Error in parsing XPath expression: ");
|
||||
err.append(attr);
|
||||
String err(NS_LITERAL_STRING("Error in parsing XPath expression: "));
|
||||
err.Append(attr);
|
||||
receiveError(err, NS_ERROR_XPATH_PARSE_FAILED);
|
||||
}
|
||||
else {
|
||||
|
@ -614,8 +614,8 @@ txPattern* ProcessorState::getPattern(Element* aElem, PatternAttr aAttr)
|
|||
pattern = txPatternParser::createPattern(attr, &pContext, this);
|
||||
|
||||
if (!pattern) {
|
||||
String err("Error in parsing pattern: ");
|
||||
err.append(attr);
|
||||
String err(NS_LITERAL_STRING("Error in parsing pattern: "));
|
||||
err.Append(attr);
|
||||
receiveError(err, NS_ERROR_XPATH_PARSE_FAILED);
|
||||
}
|
||||
else {
|
||||
|
@ -710,14 +710,14 @@ void ProcessorState::processAttrValueTemplate(const String& aAttValue,
|
|||
Element* aContext,
|
||||
String& aResult)
|
||||
{
|
||||
aResult.clear();
|
||||
aResult.Truncate();
|
||||
txPSParseContext pContext(this, aContext);
|
||||
AttributeValueTemplate* avt =
|
||||
ExprParser::createAttributeValueTemplate(aAttValue, &pContext);
|
||||
|
||||
if (!avt) {
|
||||
// fallback, just copy the attribute
|
||||
aResult.append(aAttValue);
|
||||
aResult.Append(aAttValue);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -750,7 +750,7 @@ void ProcessorState::shouldStripSpace(String& aNames, Element* aElement,
|
|||
PRInt32 aNSID = kNameSpaceID_None;
|
||||
txAtom* prefixAtom = 0;
|
||||
XMLUtils::getPrefix(name, prefix);
|
||||
if (!prefix.isEmpty()) {
|
||||
if (!prefix.IsEmpty()) {
|
||||
prefixAtom = TX_GET_ATOM(prefix);
|
||||
aNSID = aElement->lookupNamespaceID(prefixAtom);
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ MBool ProcessorState::addKey(Element* aKeyElem)
|
|||
match = txPatternParser::createPattern(attrVal, &pContext, this);
|
||||
}
|
||||
Expr* use = 0;
|
||||
attrVal.clear();
|
||||
attrVal.Truncate();
|
||||
if (aKeyElem->getAttr(txXSLTAtoms::use, kNameSpaceID_None, attrVal)) {
|
||||
use = ExprParser::createExpr(attrVal, &pContext);
|
||||
}
|
||||
|
@ -851,16 +851,16 @@ MBool ProcessorState::addDecimalFormat(Element* element)
|
|||
|
||||
if (element->getAttr(txXSLTAtoms::decimalSeparator,
|
||||
kNameSpaceID_None, attValue)) {
|
||||
if (attValue.length() == 1)
|
||||
format->mDecimalSeparator = attValue.charAt(0);
|
||||
if (attValue.Length() == 1)
|
||||
format->mDecimalSeparator = attValue.CharAt(0);
|
||||
else
|
||||
success = MB_FALSE;
|
||||
}
|
||||
|
||||
if (element->getAttr(txXSLTAtoms::groupingSeparator,
|
||||
kNameSpaceID_None, attValue)) {
|
||||
if (attValue.length() == 1)
|
||||
format->mGroupingSeparator = attValue.charAt(0);
|
||||
if (attValue.Length() == 1)
|
||||
format->mGroupingSeparator = attValue.CharAt(0);
|
||||
else
|
||||
success = MB_FALSE;
|
||||
}
|
||||
|
@ -871,8 +871,8 @@ MBool ProcessorState::addDecimalFormat(Element* element)
|
|||
|
||||
if (element->getAttr(txXSLTAtoms::minusSign,
|
||||
kNameSpaceID_None, attValue)) {
|
||||
if (attValue.length() == 1)
|
||||
format->mMinusSign = attValue.charAt(0);
|
||||
if (attValue.Length() == 1)
|
||||
format->mMinusSign = attValue.CharAt(0);
|
||||
else
|
||||
success = MB_FALSE;
|
||||
}
|
||||
|
@ -883,40 +883,40 @@ MBool ProcessorState::addDecimalFormat(Element* element)
|
|||
|
||||
if (element->getAttr(txXSLTAtoms::percent, kNameSpaceID_None,
|
||||
attValue)) {
|
||||
if (attValue.length() == 1)
|
||||
format->mPercent = attValue.charAt(0);
|
||||
if (attValue.Length() == 1)
|
||||
format->mPercent = attValue.CharAt(0);
|
||||
else
|
||||
success = MB_FALSE;
|
||||
}
|
||||
|
||||
if (element->getAttr(txXSLTAtoms::perMille,
|
||||
kNameSpaceID_None, attValue)) {
|
||||
if (attValue.length() == 1)
|
||||
format->mPerMille = attValue.charAt(0);
|
||||
else if (!attValue.isEmpty())
|
||||
if (attValue.Length() == 1)
|
||||
format->mPerMille = attValue.CharAt(0);
|
||||
else if (!attValue.IsEmpty())
|
||||
success = MB_FALSE;
|
||||
}
|
||||
|
||||
if (element->getAttr(txXSLTAtoms::zeroDigit,
|
||||
kNameSpaceID_None, attValue)) {
|
||||
if (attValue.length() == 1)
|
||||
format->mZeroDigit = attValue.charAt(0);
|
||||
else if (!attValue.isEmpty())
|
||||
if (attValue.Length() == 1)
|
||||
format->mZeroDigit = attValue.CharAt(0);
|
||||
else if (!attValue.IsEmpty())
|
||||
success = MB_FALSE;
|
||||
}
|
||||
|
||||
if (element->getAttr(txXSLTAtoms::digit, kNameSpaceID_None,
|
||||
attValue)) {
|
||||
if (attValue.length() == 1)
|
||||
format->mDigit = attValue.charAt(0);
|
||||
if (attValue.Length() == 1)
|
||||
format->mDigit = attValue.CharAt(0);
|
||||
else
|
||||
success = MB_FALSE;
|
||||
}
|
||||
|
||||
if (element->getAttr(txXSLTAtoms::patternSeparator,
|
||||
kNameSpaceID_None, attValue)) {
|
||||
if (attValue.length() == 1)
|
||||
format->mPatternSeparator = attValue.charAt(0);
|
||||
if (attValue.Length() == 1)
|
||||
format->mPatternSeparator = attValue.CharAt(0);
|
||||
else
|
||||
success = MB_FALSE;
|
||||
}
|
||||
|
@ -984,7 +984,7 @@ nsresult ProcessorState::getVariable(PRInt32 aNamespace, txAtom* aLName,
|
|||
globVar = (GlobalVariableValue*)mGlobalVariableValues.get(varName);
|
||||
if (globVar) {
|
||||
if (globVar->mFlags == GlobalVariableValue::evaluating) {
|
||||
String err("Cyclic variable-value detected");
|
||||
String err(NS_LITERAL_STRING("Cyclic variable-value detected"));
|
||||
receiveError(err, NS_ERROR_FAILURE);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
|
||||
curr = aPs->getCurrentTemplateRule();
|
||||
if (!curr) {
|
||||
String err("apply-imports not allowed here");
|
||||
String err(NS_LITERAL_STRING("apply-imports not allowed here"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -381,7 +381,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
kNameSpaceID_None, modeStr)) {
|
||||
rv = mode.init(modeStr, actionElement, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("malformed mode-name in xsl:apply-templates");
|
||||
String err(NS_LITERAL_STRING("malformed mode-name in xsl:apply-templates"));
|
||||
aPs->receiveError(err);
|
||||
TX_IF_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -403,7 +403,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
aPs->setEvalContext(priorEC);
|
||||
}
|
||||
else {
|
||||
String err("error processing apply-templates");
|
||||
String err(NS_LITERAL_STRING("error processing apply-templates"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
//-- clean up
|
||||
|
@ -414,7 +414,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
String nameAttr;
|
||||
if (!actionElement->getAttr(txXSLTAtoms::name,
|
||||
kNameSpaceID_None, nameAttr)) {
|
||||
String err("missing required name attribute for xsl:attribute");
|
||||
String err(NS_LITERAL_STRING("missing required name attribute for xsl:attribute"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -426,9 +426,9 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
|
||||
// Check name validity (must be valid QName and not xmlns)
|
||||
if (!XMLUtils::isValidQName(name)) {
|
||||
String err("error processing xsl:attribute, ");
|
||||
err.append(name);
|
||||
err.append(" is not a valid QName.");
|
||||
String err(NS_LITERAL_STRING("error processing xsl:attribute, "));
|
||||
err.Append(name);
|
||||
err.Append(NS_LITERAL_STRING(" is not a valid QName."));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -437,7 +437,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
txAtom* nameAtom = TX_GET_ATOM(name);
|
||||
if (nameAtom == txXMLAtoms::xmlns) {
|
||||
TX_RELEASE_ATOM(nameAtom);
|
||||
String err("error processing xsl:attribute, name is xmlns.");
|
||||
String err(NS_LITERAL_STRING("error processing xsl:attribute, name is xmlns."));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -464,7 +464,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
resultNsID = actionElement->lookupNamespaceID(prefixAtom);
|
||||
else
|
||||
// Cut xmlns: (6 characters)
|
||||
name.deleteChars(0, 6);
|
||||
name.Cut(0, 6);
|
||||
}
|
||||
TX_IF_RELEASE_ATOM(prefixAtom);
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
}
|
||||
}
|
||||
else {
|
||||
String err("missing or malformed name in xsl:call-template");
|
||||
String err(NS_LITERAL_STRING("missing or malformed name in xsl:call-template"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -554,10 +554,10 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
String value;
|
||||
processChildrenAsValue(actionElement, aPs, MB_TRUE, value);
|
||||
PRInt32 pos = 0;
|
||||
PRUint32 length = value.length();
|
||||
PRUint32 length = value.Length();
|
||||
while ((pos = value.indexOf('-', pos)) != kNotFound) {
|
||||
++pos;
|
||||
if (((PRUint32)pos == length) || (value.charAt(pos) == '-')) {
|
||||
if (((PRUint32)pos == length) || (value.CharAt(pos) == '-')) {
|
||||
value.insert(pos++, ' ');
|
||||
++length;
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
String nameAttr;
|
||||
if (!actionElement->getAttr(txXSLTAtoms::name,
|
||||
kNameSpaceID_None, nameAttr)) {
|
||||
String err("missing required name attribute for xsl:element");
|
||||
String err(NS_LITERAL_STRING("missing required name attribute for xsl:element"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -598,9 +598,9 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
|
||||
// Check name validity (must be valid QName and not xmlns)
|
||||
if (!XMLUtils::isValidQName(name)) {
|
||||
String err("error processing xsl:element, '");
|
||||
err.append(name);
|
||||
err.append("' is not a valid QName.");
|
||||
String err(NS_LITERAL_STRING("error processing xsl:element, '"));
|
||||
err.Append(name);
|
||||
err.Append(NS_LITERAL_STRING("' is not a valid QName."));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
// XXX We should processChildren without creating attributes or
|
||||
// namespace nodes.
|
||||
|
@ -615,7 +615,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
if (actionElement->getAttr(txXSLTAtoms::_namespace, kNameSpaceID_None, resultNs)) {
|
||||
String nsURI;
|
||||
aPs->processAttrValueTemplate(resultNs, actionElement, nsURI);
|
||||
if (nsURI.isEmpty())
|
||||
if (nsURI.IsEmpty())
|
||||
resultNsID = kNameSpaceID_None;
|
||||
else
|
||||
resultNsID = aPs->getStylesheetDocument()->namespaceURIToID(nsURI);
|
||||
|
@ -629,9 +629,9 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
}
|
||||
|
||||
if (resultNsID == kNameSpaceID_Unknown) {
|
||||
String err("error processing xsl:element, can't resolve prefix on'");
|
||||
err.append(name);
|
||||
err.append("'.");
|
||||
String err(NS_LITERAL_STRING("error processing xsl:element, can't resolve prefix on'"));
|
||||
err.Append(name);
|
||||
err.Append(NS_LITERAL_STRING("'."));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
// XXX We should processChildren without creating attributes or
|
||||
// namespace nodes.
|
||||
|
@ -712,7 +712,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
aPs->setEvalContext(priorEC);
|
||||
}
|
||||
else {
|
||||
String err("error processing for-each");
|
||||
String err(NS_LITERAL_STRING("error processing for-each"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
//-- clean up exprResult
|
||||
|
@ -754,7 +754,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
}
|
||||
// xsl:param
|
||||
else if (localName == txXSLTAtoms::param) {
|
||||
String err("misplaced xsl:param");
|
||||
String err(NS_LITERAL_STRING("misplaced xsl:param"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
// xsl:processing-instruction
|
||||
|
@ -762,8 +762,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
String nameAttr;
|
||||
if (!actionElement->getAttr(txXSLTAtoms::name,
|
||||
kNameSpaceID_None, nameAttr)) {
|
||||
String err("missing required name attribute for"
|
||||
" xsl:processing-instruction");
|
||||
String err(NS_LITERAL_STRING("missing required name attribute for xsl:processing-instruction"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -776,9 +775,9 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
// Check name validity (must be valid NCName and a PITarget)
|
||||
// XXX Need to check for NCName and PITarget
|
||||
if (!XMLUtils::isValidQName(name)) {
|
||||
String err("error processing xsl:processing-instruction, '");
|
||||
err.append(name);
|
||||
err.append("' is not a valid QName.");
|
||||
String err(NS_LITERAL_STRING("error processing xsl:processing-instruction, '"));
|
||||
err.Append(name);
|
||||
err.Append(NS_LITERAL_STRING("' is not a valid QName."));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -805,7 +804,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
String attValue;
|
||||
doe = actionElement->getAttr(txXSLTAtoms::disableOutputEscaping,
|
||||
kNameSpaceID_None, attValue) &&
|
||||
attValue.isEqual(YES_VALUE);
|
||||
attValue.Equals(YES_VALUE);
|
||||
}
|
||||
if (doe) {
|
||||
aPs->mOutputHandler->charactersNoOutputEscaping(data);
|
||||
|
@ -825,7 +824,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
ExprResult* exprResult = expr->evaluate(aPs->getEvalContext());
|
||||
String value;
|
||||
if (!exprResult) {
|
||||
String err("null ExprResult");
|
||||
String err(NS_LITERAL_STRING("null ExprResult"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -839,7 +838,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
String attValue;
|
||||
doe = actionElement->getAttr(txXSLTAtoms::disableOutputEscaping,
|
||||
kNameSpaceID_None, attValue) &&
|
||||
attValue.isEqual(YES_VALUE);
|
||||
attValue.Equals(YES_VALUE);
|
||||
}
|
||||
if (doe) {
|
||||
aPs->mOutputHandler->charactersNoOutputEscaping(value);
|
||||
|
@ -857,7 +856,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
qName);
|
||||
rv = varName.init(qName, actionElement, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("bad name for xsl:variable");
|
||||
String err(NS_LITERAL_STRING("bad name for xsl:variable"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
TX_RELEASE_ATOM(localName);
|
||||
return;
|
||||
|
@ -872,7 +871,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
|||
NS_ASSERTION(vars, "missing localvariable map");
|
||||
rv = vars->bindVariable(varName, exprResult, MB_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("bad name for xsl:variable");
|
||||
String err(NS_LITERAL_STRING("bad name for xsl:variable"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -891,7 +890,7 @@ txXSLTProcessor::processAttributeSets(Element* aElement,
|
|||
namespaceID = kNameSpaceID_None;
|
||||
else
|
||||
namespaceID = kNameSpaceID_XSLT;
|
||||
if (!aElement->getAttr(txXSLTAtoms::useAttributeSets, namespaceID, names) || names.isEmpty())
|
||||
if (!aElement->getAttr(txXSLTAtoms::useAttributeSets, namespaceID, names) || names.IsEmpty())
|
||||
return;
|
||||
|
||||
// Split names
|
||||
|
@ -902,7 +901,7 @@ txXSLTProcessor::processAttributeSets(Element* aElement,
|
|||
txExpandedName name;
|
||||
rv = name.init(nameStr, aElement, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("missing or malformed name in use-attribute-sets");
|
||||
String err(NS_LITERAL_STRING("missing or malformed name in use-attribute-sets"));
|
||||
aPs->receiveError(err);
|
||||
return;
|
||||
}
|
||||
|
@ -911,7 +910,7 @@ txXSLTProcessor::processAttributeSets(Element* aElement,
|
|||
txStackIterator attributeSets(aRecursionStack);
|
||||
while (attributeSets.hasNext()) {
|
||||
if (name == *(txExpandedName*)attributeSets.next()) {
|
||||
String err("circular inclusion detected in use-attribute-sets");
|
||||
String err(NS_LITERAL_STRING("circular inclusion detected in use-attribute-sets"));
|
||||
aPs->receiveError(err);
|
||||
return;
|
||||
}
|
||||
|
@ -992,7 +991,7 @@ txXSLTProcessor::processDefaultTemplate(ProcessorState* aPs,
|
|||
ExprResult* exprResult = gNodeExpr->evaluate(aPs->getEvalContext());
|
||||
if (!exprResult ||
|
||||
exprResult->getResultType() != ExprResult::NODESET) {
|
||||
String err("None-nodeset returned while processing default template");
|
||||
String err(NS_LITERAL_STRING("None-nodeset returned while processing default template"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
delete exprResult;
|
||||
return;
|
||||
|
@ -1041,9 +1040,9 @@ txXSLTProcessor::processInclude(String& aHref,
|
|||
// make sure the include isn't included yet
|
||||
txStackIterator iter(aPs->getEnteredStylesheets());
|
||||
while (iter.hasNext()) {
|
||||
if (((String*)iter.next())->isEqual(aHref)) {
|
||||
String err("Stylesheet includes itself. URI: ");
|
||||
err.append(aHref);
|
||||
if (((String*)iter.next())->Equals(aHref)) {
|
||||
String err(NS_LITERAL_STRING("Stylesheet includes itself. URI: "));
|
||||
err.Append(aHref);
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
@ -1053,8 +1052,8 @@ txXSLTProcessor::processInclude(String& aHref,
|
|||
// Load XSL document
|
||||
Node* stylesheet = aPs->retrieveDocument(aHref, String());
|
||||
if (!stylesheet) {
|
||||
String err("Unable to load included stylesheet ");
|
||||
err.append(aHref);
|
||||
String err(NS_LITERAL_STRING("Unable to load included stylesheet "));
|
||||
err.Append(aHref);
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
aPs->getEnteredStylesheets()->pop();
|
||||
return;
|
||||
|
@ -1071,7 +1070,7 @@ txXSLTProcessor::processInclude(String& aHref,
|
|||
break;
|
||||
default:
|
||||
// This should never happen
|
||||
String err("Unsupported fragment identifier");
|
||||
String err(NS_LITERAL_STRING("Unsupported fragment identifier"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
@ -1129,7 +1128,7 @@ txXSLTProcessor::processParameters(Element* aAction,
|
|||
action->getAttr(txXSLTAtoms::name, kNameSpaceID_None, qName);
|
||||
rv = paramName.init(qName, action, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("bad name for xsl:param");
|
||||
String err(NS_LITERAL_STRING("bad name for xsl:param"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
@ -1141,9 +1140,9 @@ txXSLTProcessor::processParameters(Element* aAction,
|
|||
|
||||
rv = aMap->bindVariable(paramName, exprResult, MB_TRUE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("Unable to bind parameter '");
|
||||
err.append(qName);
|
||||
err.append("'");
|
||||
String err(NS_LITERAL_STRING("Unable to bind parameter '"));
|
||||
err.Append(qName);
|
||||
err.Append(PRUnichar('\''));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
return rv;
|
||||
}
|
||||
|
@ -1234,7 +1233,7 @@ txXSLTProcessor::processTemplate(Node* aTemplate,
|
|||
action->getAttr(txXSLTAtoms::name, kNameSpaceID_None, qName);
|
||||
rv = paramName.init(qName, action, MB_FALSE);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("bad name for xsl:param");
|
||||
String err(NS_LITERAL_STRING("bad name for xsl:param"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
break;
|
||||
}
|
||||
|
@ -1251,7 +1250,7 @@ txXSLTProcessor::processTemplate(Node* aTemplate,
|
|||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("unable to bind xsl:param");
|
||||
String err(NS_LITERAL_STRING("unable to bind xsl:param"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -1369,16 +1368,16 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
String fName;
|
||||
element->getAttr(txXSLTAtoms::name, kNameSpaceID_None,
|
||||
fName);
|
||||
String err("unable to add ");
|
||||
if (fName.isEmpty()) {
|
||||
err.append("default");
|
||||
String err(NS_LITERAL_STRING("unable to add "));
|
||||
if (fName.IsEmpty()) {
|
||||
err.Append(NS_LITERAL_STRING("default"));
|
||||
}
|
||||
else {
|
||||
err.append("\"");
|
||||
err.append(fName);
|
||||
err.append("\"");
|
||||
err.Append(PRUnichar('\"'));
|
||||
err.Append(fName);
|
||||
err.Append(PRUnichar('\"'));
|
||||
}
|
||||
err.append(" decimal format for xsl:decimal-format");
|
||||
err.Append(NS_LITERAL_STRING(" decimal format for xsl:decimal-format"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -1401,18 +1400,18 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
rv = aPs->addGlobalVariable(varName, element, currentFrame,
|
||||
defaultValue);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("unable to add global xsl:param");
|
||||
String err(NS_LITERAL_STRING("unable to add global xsl:param"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String err("unable to add global xsl:param");
|
||||
String err(NS_LITERAL_STRING("unable to add global xsl:param"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
// xsl:import
|
||||
else if (localName == txXSLTAtoms::import) {
|
||||
String err("xsl:import only allowed at top of stylesheet");
|
||||
String err(NS_LITERAL_STRING("xsl:import only allowed at top of stylesheet"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
// xsl:include
|
||||
|
@ -1431,9 +1430,9 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
String name;
|
||||
element->getAttr(txXSLTAtoms::name, kNameSpaceID_None,
|
||||
name);
|
||||
String err("error adding key '");
|
||||
err.append(name);
|
||||
err.append("'");
|
||||
String err(NS_LITERAL_STRING("error adding key '"));
|
||||
err.Append(name);
|
||||
err.Append(PRUnichar('\''));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -1444,10 +1443,10 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
|
||||
if (element->getAttr(txXSLTAtoms::method, kNameSpaceID_None,
|
||||
attValue)) {
|
||||
if (attValue.isEqual("html")) {
|
||||
if (attValue.getConstNSString().Equals(NS_LITERAL_STRING("html"))) {
|
||||
format.mMethod = eHTMLOutput;
|
||||
}
|
||||
else if (attValue.isEqual("text")) {
|
||||
else if (attValue.getConstNSString().Equals(NS_LITERAL_STRING("text"))) {
|
||||
format.mMethod = eTextOutput;
|
||||
}
|
||||
else {
|
||||
|
@ -1467,12 +1466,12 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
|
||||
if (element->getAttr(txXSLTAtoms::omitXmlDeclaration,
|
||||
kNameSpaceID_None, attValue)) {
|
||||
format.mOmitXMLDeclaration = attValue.isEqual(YES_VALUE) ? eTrue : eFalse;
|
||||
format.mOmitXMLDeclaration = attValue.Equals(YES_VALUE) ? eTrue : eFalse;
|
||||
}
|
||||
|
||||
if (element->getAttr(txXSLTAtoms::standalone, kNameSpaceID_None,
|
||||
attValue)) {
|
||||
format.mStandalone = attValue.isEqual(YES_VALUE) ? eTrue : eFalse;
|
||||
format.mStandalone = attValue.Equals(YES_VALUE) ? eTrue : eFalse;
|
||||
}
|
||||
|
||||
if (element->getAttr(txXSLTAtoms::doctypePublic,
|
||||
|
@ -1522,7 +1521,7 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
|
||||
if (element->getAttr(txXSLTAtoms::indent, kNameSpaceID_None,
|
||||
attValue)) {
|
||||
format.mIndent = attValue.isEqual(YES_VALUE) ? eTrue : eFalse;
|
||||
format.mIndent = attValue.Equals(YES_VALUE) ? eTrue : eFalse;
|
||||
}
|
||||
|
||||
if (element->getAttr(txXSLTAtoms::mediaType, kNameSpaceID_None,
|
||||
|
@ -1544,12 +1543,12 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
rv = aPs->addGlobalVariable(varName, element, currentFrame,
|
||||
0);
|
||||
if (NS_FAILED(rv)) {
|
||||
String err("unable to add global xsl:variable");
|
||||
String err(NS_LITERAL_STRING("unable to add global xsl:variable"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String err("unable to add global xsl:variable");
|
||||
String err(NS_LITERAL_STRING("unable to add global xsl:variable"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -1559,8 +1558,8 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
if (!element->getAttr(txXSLTAtoms::elements,
|
||||
kNameSpaceID_None, elements)) {
|
||||
//-- add error to ErrorObserver
|
||||
String err("missing required 'elements' attribute for ");
|
||||
err.append("xsl:preserve-space");
|
||||
String err(NS_LITERAL_STRING("missing required 'elements' attribute for "));
|
||||
err.Append(NS_LITERAL_STRING("xsl:preserve-space"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
else {
|
||||
|
@ -1575,8 +1574,8 @@ txXSLTProcessor::processTopLevel(Element* aStylesheet,
|
|||
if (!element->getAttr(txXSLTAtoms::elements,
|
||||
kNameSpaceID_None, elements)) {
|
||||
//-- add error to ErrorObserver
|
||||
String err("missing required 'elements' attribute for ");
|
||||
err.append("xsl:strip-space");
|
||||
String err(NS_LITERAL_STRING("missing required 'elements' attribute for "));
|
||||
err.Append(NS_LITERAL_STRING("xsl:strip-space"));
|
||||
aPs->receiveError(err, NS_ERROR_FAILURE);
|
||||
}
|
||||
else {
|
||||
|
@ -1600,7 +1599,7 @@ txXSLTProcessor::processVariable(Element* aVariable,
|
|||
if (aVariable->hasAttr(txXSLTAtoms::select, kNameSpaceID_None)) {
|
||||
Expr* expr = aPs->getExpr(aVariable, ProcessorState::SelectAttr);
|
||||
if (!expr)
|
||||
return new StringResult("unable to process variable");
|
||||
return new StringResult(NS_LITERAL_STRING("unable to process variable"));
|
||||
return expr->evaluate(aPs->getEvalContext());
|
||||
}
|
||||
if (aVariable->hasChildNodes()) {
|
||||
|
|
|
@ -77,7 +77,7 @@ ExprResult* DocumentFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
Expr* param2 = (Expr*)iter.next();
|
||||
ExprResult* exprResult2 = param2->evaluate(aContext);
|
||||
if (exprResult2->getResultType() != ExprResult::NODESET) {
|
||||
String err("node-set expected as second argument to document(): ");
|
||||
String err(NS_LITERAL_STRING("node-set expected as second argument to document(): "));
|
||||
toString(err);
|
||||
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
|
||||
delete exprResult1;
|
||||
|
|
|
@ -119,7 +119,7 @@ ExprResult* ElementAvailableFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
}
|
||||
}
|
||||
else {
|
||||
String err("Invalid argument passed to element-available(), expecting String");
|
||||
String err(NS_LITERAL_STRING("Invalid argument passed to element-available(), expecting String"));
|
||||
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
|
||||
result = new StringResult(err);
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ ExprResult* FunctionAvailableFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
}
|
||||
}
|
||||
else {
|
||||
String err("Invalid argument passed to function-available, expecting String");
|
||||
String err(NS_LITERAL_STRING("Invalid argument passed to function-available, expecting String"));
|
||||
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
|
||||
result = new StringResult(err);
|
||||
}
|
||||
|
|
|
@ -73,8 +73,7 @@ ExprResult* GenerateIdFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
return 0;
|
||||
|
||||
if (exprResult->getResultType() != ExprResult::NODESET) {
|
||||
String err("Invalid argument passed to generate-id(), "
|
||||
"expecting NodeSet");
|
||||
String err(NS_LITERAL_STRING("Invalid argument passed to generate-id(), expecting NodeSet"));
|
||||
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
|
||||
delete exprResult;
|
||||
return new StringResult(err);
|
||||
|
@ -99,7 +98,7 @@ ExprResult* GenerateIdFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
#else
|
||||
PR_snprintf(buf, 21, printfFmt, node);
|
||||
#endif
|
||||
return new StringResult(buf);
|
||||
return new StringResult(NS_ConvertASCIItoUCS2(buf));
|
||||
}
|
||||
|
||||
nsresult GenerateIdFunctionCall::getNameAtom(txAtom** aAtom)
|
||||
|
|
|
@ -44,22 +44,22 @@ ExprResult* SystemPropertyFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
result = new NumberResult(1.0);
|
||||
}
|
||||
else if (qname.mLocalName == txXSLTAtoms::vendor) {
|
||||
result = new StringResult("Transformiix");
|
||||
result = new StringResult(NS_LITERAL_STRING("Transformiix"));
|
||||
}
|
||||
else if (qname.mLocalName == txXSLTAtoms::vendorUrl) {
|
||||
result = new StringResult("http://www.mozilla.org/projects/xslt/");
|
||||
result = new StringResult(NS_LITERAL_STRING("http://www.mozilla.org/projects/xslt/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
String err("Invalid argument passed to system-property(), expecting String");
|
||||
String err(NS_LITERAL_STRING("Invalid argument passed to system-property(), expecting String"));
|
||||
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
|
||||
result = new StringResult(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
result = new StringResult("");
|
||||
result = new StringResult();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ public:
|
|||
TX_DECL_FUNCTION;
|
||||
|
||||
private:
|
||||
static const UNICODE_CHAR FORMAT_QUOTE;
|
||||
static const PRUnichar FORMAT_QUOTE;
|
||||
|
||||
enum FormatParseState {
|
||||
Prefix,
|
||||
|
@ -209,16 +209,16 @@ public:
|
|||
txDecimalFormat();
|
||||
MBool isEqual(txDecimalFormat* other);
|
||||
|
||||
UNICODE_CHAR mDecimalSeparator;
|
||||
UNICODE_CHAR mGroupingSeparator;
|
||||
PRUnichar mDecimalSeparator;
|
||||
PRUnichar mGroupingSeparator;
|
||||
String mInfinity;
|
||||
UNICODE_CHAR mMinusSign;
|
||||
PRUnichar mMinusSign;
|
||||
String mNaN;
|
||||
UNICODE_CHAR mPercent;
|
||||
UNICODE_CHAR mPerMille;
|
||||
UNICODE_CHAR mZeroDigit;
|
||||
UNICODE_CHAR mDigit;
|
||||
UNICODE_CHAR mPatternSeparator;
|
||||
PRUnichar mPercent;
|
||||
PRUnichar mPerMille;
|
||||
PRUnichar mZeroDigit;
|
||||
PRUnichar mDigit;
|
||||
PRUnichar mPatternSeparator;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
const UNICODE_CHAR txFormatNumberFunctionCall::FORMAT_QUOTE = '\'';
|
||||
const PRUnichar txFormatNumberFunctionCall::FORMAT_QUOTE = '\'';
|
||||
|
||||
/*
|
||||
* FormatNumberFunctionCall
|
||||
|
@ -98,7 +98,7 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
|
||||
txDecimalFormat* format = mPs->getDecimalFormat(formatName);
|
||||
if (!format) {
|
||||
String err("unknown decimal format for: ");
|
||||
String err(NS_LITERAL_STRING("unknown decimal format for: "));
|
||||
toString(err);
|
||||
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
|
||||
return new StringResult(err);
|
||||
|
@ -113,8 +113,8 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
|
||||
if (value == Double::NEGATIVE_INFINITY) {
|
||||
String res;
|
||||
res.append(format->mMinusSign);
|
||||
res.append(format->mInfinity);
|
||||
res.Append(format->mMinusSign);
|
||||
res.Append(format->mInfinity);
|
||||
return new StringResult(res);
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
int groupSize=-1;
|
||||
|
||||
PRUint32 pos = 0;
|
||||
PRUint32 formatLen = formatStr.length();
|
||||
PRUint32 formatLen = formatStr.Length();
|
||||
MBool inQuote;
|
||||
|
||||
// Get right subexpression
|
||||
|
@ -136,15 +136,15 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
if (Double::isNeg(value)) {
|
||||
while (pos < formatLen &&
|
||||
(inQuote ||
|
||||
formatStr.charAt(pos) != format->mPatternSeparator)) {
|
||||
if (formatStr.charAt(pos) == FORMAT_QUOTE)
|
||||
formatStr.CharAt(pos) != format->mPatternSeparator)) {
|
||||
if (formatStr.CharAt(pos) == FORMAT_QUOTE)
|
||||
inQuote = !inQuote;
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (pos == formatLen) {
|
||||
pos = 0;
|
||||
prefix.append(format->mMinusSign);
|
||||
prefix.Append(format->mMinusSign);
|
||||
}
|
||||
else
|
||||
pos++;
|
||||
|
@ -154,9 +154,9 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
FormatParseState pState = Prefix;
|
||||
inQuote = MB_FALSE;
|
||||
|
||||
UNICODE_CHAR c = 0;
|
||||
PRUnichar c = 0;
|
||||
while (pos < formatLen && pState != Finished) {
|
||||
c=formatStr.charAt(pos++);
|
||||
c=formatStr.CharAt(pos++);
|
||||
|
||||
switch (pState) {
|
||||
|
||||
|
@ -199,9 +199,9 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
if (c == FORMAT_QUOTE)
|
||||
inQuote = !inQuote;
|
||||
else if (pState == Prefix)
|
||||
prefix.append(c);
|
||||
prefix.Append(c);
|
||||
else
|
||||
suffix.append(c);
|
||||
suffix.Append(c);
|
||||
break;
|
||||
|
||||
case IntDigit:
|
||||
|
@ -321,9 +321,9 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
int i;
|
||||
for (i = 0; i < intDigits; ++i) {
|
||||
if ((intDigits-i)%groupSize == 0 && i != 0)
|
||||
res.append(format->mGroupingSeparator);
|
||||
res.Append(format->mGroupingSeparator);
|
||||
|
||||
res.append((UNICODE_CHAR)(buf[i] - '0' + format->mZeroDigit));
|
||||
res.Append((PRUnichar)(buf[i] - '0' + format->mZeroDigit));
|
||||
}
|
||||
|
||||
// Fractions
|
||||
|
@ -339,22 +339,22 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
}
|
||||
else {
|
||||
if (printDeci) {
|
||||
res.append(format->mDecimalSeparator);
|
||||
res.Append(format->mDecimalSeparator);
|
||||
printDeci = MB_FALSE;
|
||||
}
|
||||
while (extraZeros) {
|
||||
res.append(format->mZeroDigit);
|
||||
res.Append(format->mZeroDigit);
|
||||
extraZeros--;
|
||||
}
|
||||
|
||||
res.append((UNICODE_CHAR)(buf[i] - '0' + format->mZeroDigit));
|
||||
res.Append((PRUnichar)(buf[i] - '0' + format->mZeroDigit));
|
||||
}
|
||||
}
|
||||
|
||||
if (!intDigits && printDeci) {
|
||||
// If we havn't added any characters we add a '0'
|
||||
// This can only happen for formats like '##.##'
|
||||
res.append(format->mZeroDigit);
|
||||
res.Append(format->mZeroDigit);
|
||||
}
|
||||
|
||||
delete [] buf;
|
||||
|
@ -386,7 +386,7 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
groupSize = intDigits + 10; //to simplify grouping
|
||||
|
||||
// XXX We shouldn't use SetLength.
|
||||
res.getNSString().SetLength(res.length() +
|
||||
res.getNSString().SetLength(res.Length() +
|
||||
intDigits + // integer digits
|
||||
1 + // decimal separator
|
||||
maxFractionSize + // fractions
|
||||
|
@ -396,7 +396,7 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
MBool carry = (i+1 < buflen) && (buf[i+1] >= '5');
|
||||
MBool hasFraction = MB_FALSE;
|
||||
|
||||
PRUint32 resPos = res.length()-1;
|
||||
PRUint32 resPos = res.Length()-1;
|
||||
|
||||
// Fractions
|
||||
for (; i >= bufIntDigits; --i) {
|
||||
|
@ -416,10 +416,10 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
if (hasFraction || digit != 0 || i < bufIntDigits+minFractionSize) {
|
||||
hasFraction = MB_TRUE;
|
||||
res.replace(resPos--,
|
||||
(UNICODE_CHAR)(digit + format->mZeroDigit));
|
||||
(PRUnichar)(digit + format->mZeroDigit));
|
||||
}
|
||||
else {
|
||||
res.truncate(resPos--);
|
||||
res.Truncate(resPos--);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
res.replace(resPos--, format->mDecimalSeparator);
|
||||
}
|
||||
else {
|
||||
res.truncate(resPos--);
|
||||
res.Truncate(resPos--);
|
||||
}
|
||||
|
||||
// Integer digits
|
||||
|
@ -450,20 +450,20 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
res.replace(resPos--, format->mGroupingSeparator);
|
||||
}
|
||||
|
||||
res.replace(resPos--, (UNICODE_CHAR)(digit + format->mZeroDigit));
|
||||
res.replace(resPos--, (PRUnichar)(digit + format->mZeroDigit));
|
||||
}
|
||||
|
||||
if (carry) {
|
||||
if (i%groupSize == 0) {
|
||||
res.insert(resPos + 1, format->mGroupingSeparator);
|
||||
}
|
||||
res.insert(resPos + 1, (UNICODE_CHAR)(1 + format->mZeroDigit));
|
||||
res.insert(resPos + 1, (PRUnichar)(1 + format->mZeroDigit));
|
||||
}
|
||||
|
||||
if (!hasFraction && !intDigits && !carry) {
|
||||
// If we havn't added any characters we add a '0'
|
||||
// This can only happen for formats like '##.##'
|
||||
res.append(format->mZeroDigit);
|
||||
res.Append(format->mZeroDigit);
|
||||
}
|
||||
|
||||
delete [] buf;
|
||||
|
@ -471,7 +471,7 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
#endif // TX_EXE
|
||||
|
||||
// Build suffix
|
||||
res.append(suffix);
|
||||
res.Append(suffix);
|
||||
|
||||
return new StringResult(res);
|
||||
} //-- evaluate
|
||||
|
@ -488,8 +488,8 @@ nsresult txFormatNumberFunctionCall::getNameAtom(txAtom** aAtom)
|
|||
* A representation of the XSLT element <xsl:decimal-format>
|
||||
*/
|
||||
|
||||
txDecimalFormat::txDecimalFormat() : mInfinity("Infinity"),
|
||||
mNaN("NaN")
|
||||
txDecimalFormat::txDecimalFormat() : mInfinity(NS_LITERAL_STRING("Infinity")),
|
||||
mNaN(NS_LITERAL_STRING("NaN"))
|
||||
{
|
||||
mDecimalSeparator = '.';
|
||||
mGroupingSeparator = ',';
|
||||
|
@ -505,9 +505,9 @@ MBool txDecimalFormat::isEqual(txDecimalFormat* other)
|
|||
{
|
||||
return mDecimalSeparator == other->mDecimalSeparator &&
|
||||
mGroupingSeparator == other->mGroupingSeparator &&
|
||||
mInfinity.isEqual(other->mInfinity) &&
|
||||
mInfinity.Equals(other->mInfinity) &&
|
||||
mMinusSign == other->mMinusSign &&
|
||||
mNaN.isEqual(other->mNaN) &&
|
||||
mNaN.Equals(other->mNaN) &&
|
||||
mPercent == other->mPercent &&
|
||||
mPerMille == other->mPerMille &&
|
||||
mZeroDigit == other->mZeroDigit &&
|
||||
|
|
|
@ -50,7 +50,7 @@ txKeyFunctionCall::txKeyFunctionCall(ProcessorState* aPs,
|
|||
ExprResult* txKeyFunctionCall::evaluate(txIEvalContext* aContext)
|
||||
{
|
||||
if (!aContext || !requireParams(2, 2, aContext))
|
||||
return new StringResult("error");
|
||||
return new StringResult(NS_LITERAL_STRING("error"));
|
||||
|
||||
NodeSet* res = new NodeSet;
|
||||
if (!res) {
|
||||
|
@ -71,7 +71,7 @@ ExprResult* txKeyFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
}
|
||||
|
||||
if (!key) {
|
||||
String err("No key with that name in: ");
|
||||
String err(NS_LITERAL_STRING("No key with that name in: "));
|
||||
toString(err);
|
||||
aContext->receiveError(err, NS_ERROR_INVALID_ARG);
|
||||
return res;
|
||||
|
@ -252,7 +252,7 @@ void txXSLKey::testNode(Node* aNode, NamedMap* aMap)
|
|||
if (exprResult->getResultType() == ExprResult::NODESET) {
|
||||
NodeSet* res = (NodeSet*)exprResult;
|
||||
for (int i=0; i<res->size(); i++) {
|
||||
val.clear();
|
||||
val.Truncate();
|
||||
XMLDOMUtils::getNodeValue(res->get(i), val);
|
||||
|
||||
nodeSet = (NodeSet*)aMap->get(val);
|
||||
|
|
|
@ -704,7 +704,7 @@ txMozillaXMLOutput::createResultDocument(const String& aName, PRInt32 aNsID,
|
|||
}
|
||||
|
||||
// Add a doc-type if requested
|
||||
if (!mOutputFormat.mSystemId.isEmpty()) {
|
||||
if (!mOutputFormat.mSystemId.IsEmpty()) {
|
||||
nsCOMPtr<nsIDOMDOMImplementation> implementation;
|
||||
rv = aSourceDocument->GetImplementation(getter_AddRefs(implementation));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -56,17 +56,17 @@ txOutputFormat::~txOutputFormat()
|
|||
void txOutputFormat::reset()
|
||||
{
|
||||
mMethod = eMethodNotSet;
|
||||
mVersion.clear();
|
||||
if (mEncoding.isEmpty())
|
||||
mVersion.Truncate();
|
||||
if (mEncoding.IsEmpty())
|
||||
mOmitXMLDeclaration = eNotSet;
|
||||
mStandalone = eNotSet;
|
||||
mPublicId.clear();
|
||||
mSystemId.clear();
|
||||
mPublicId.Truncate();
|
||||
mSystemId.Truncate();
|
||||
txListIterator iter(&mCDATASectionElements);
|
||||
while (iter.hasNext())
|
||||
delete (txExpandedName*)iter.next();
|
||||
mIndent = eNotSet;
|
||||
mMediaType.clear();
|
||||
mMediaType.Truncate();
|
||||
}
|
||||
|
||||
void txOutputFormat::merge(txOutputFormat& aOutputFormat)
|
||||
|
@ -74,10 +74,10 @@ void txOutputFormat::merge(txOutputFormat& aOutputFormat)
|
|||
if (mMethod == eMethodNotSet)
|
||||
mMethod = aOutputFormat.mMethod;
|
||||
|
||||
if (mVersion.isEmpty())
|
||||
if (mVersion.IsEmpty())
|
||||
mVersion = aOutputFormat.mVersion;
|
||||
|
||||
if (mEncoding.isEmpty())
|
||||
if (mEncoding.IsEmpty())
|
||||
mEncoding = aOutputFormat.mEncoding;
|
||||
|
||||
if (mOmitXMLDeclaration == eNotSet)
|
||||
|
@ -86,10 +86,10 @@ void txOutputFormat::merge(txOutputFormat& aOutputFormat)
|
|||
if (mStandalone == eNotSet)
|
||||
mStandalone = aOutputFormat.mStandalone;
|
||||
|
||||
if (mPublicId.isEmpty())
|
||||
if (mPublicId.IsEmpty())
|
||||
mPublicId = aOutputFormat.mPublicId;
|
||||
|
||||
if (mSystemId.isEmpty())
|
||||
if (mSystemId.IsEmpty())
|
||||
mSystemId = aOutputFormat.mSystemId;
|
||||
|
||||
txListIterator iter(&aOutputFormat.mCDATASectionElements);
|
||||
|
@ -103,7 +103,7 @@ void txOutputFormat::merge(txOutputFormat& aOutputFormat)
|
|||
if (mIndent == eNotSet)
|
||||
mIndent = aOutputFormat.mIndent;
|
||||
|
||||
if (mMediaType.isEmpty())
|
||||
if (mMediaType.IsEmpty())
|
||||
mMediaType = aOutputFormat.mMediaType;
|
||||
}
|
||||
|
||||
|
@ -117,11 +117,11 @@ void txOutputFormat::setFromDefaults()
|
|||
}
|
||||
case eXMLOutput:
|
||||
{
|
||||
if (mVersion.isEmpty())
|
||||
mVersion.append("1.0");
|
||||
if (mVersion.IsEmpty())
|
||||
mVersion.Append(NS_LITERAL_STRING("1.0"));
|
||||
|
||||
if (mEncoding.isEmpty())
|
||||
mEncoding.append("UTF-8");
|
||||
if (mEncoding.IsEmpty())
|
||||
mEncoding.Append(NS_LITERAL_STRING("UTF-8"));
|
||||
|
||||
if (mOmitXMLDeclaration == eNotSet)
|
||||
mOmitXMLDeclaration = eFalse;
|
||||
|
@ -129,34 +129,34 @@ void txOutputFormat::setFromDefaults()
|
|||
if (mIndent == eNotSet)
|
||||
mIndent = eFalse;
|
||||
|
||||
if (mMediaType.isEmpty())
|
||||
mMediaType.append("text/xml");
|
||||
if (mMediaType.IsEmpty())
|
||||
mMediaType.Append(NS_LITERAL_STRING("text/xml"));
|
||||
|
||||
break;
|
||||
}
|
||||
case eHTMLOutput:
|
||||
{
|
||||
if (mVersion.isEmpty())
|
||||
mVersion.append("4.0");
|
||||
if (mVersion.IsEmpty())
|
||||
mVersion.Append(NS_LITERAL_STRING("4.0"));
|
||||
|
||||
if (mEncoding.isEmpty())
|
||||
mEncoding.append("UTF-8");
|
||||
if (mEncoding.IsEmpty())
|
||||
mEncoding.Append(NS_LITERAL_STRING("UTF-8"));
|
||||
|
||||
if (mIndent == eNotSet)
|
||||
mIndent = eTrue;
|
||||
|
||||
if (mMediaType.isEmpty())
|
||||
mMediaType.append("text/html");
|
||||
if (mMediaType.IsEmpty())
|
||||
mMediaType.Append(NS_LITERAL_STRING("text/html"));
|
||||
|
||||
break;
|
||||
}
|
||||
case eTextOutput:
|
||||
{
|
||||
if (mEncoding.isEmpty())
|
||||
mEncoding.append("UTF-8");
|
||||
if (mEncoding.IsEmpty())
|
||||
mEncoding.Append(NS_LITERAL_STRING("UTF-8"));
|
||||
|
||||
if (mMediaType.isEmpty())
|
||||
mMediaType.append("text/plain");
|
||||
if (mMediaType.IsEmpty())
|
||||
mMediaType.Append(NS_LITERAL_STRING("text/plain"));
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -285,10 +285,10 @@ nsresult txPatternParser::createStepPattern(ExprLexer& aLexer,
|
|||
MBool isAttr = MB_FALSE;
|
||||
Token* tok = aLexer.peek();
|
||||
if (tok->type == Token::AXIS_IDENTIFIER) {
|
||||
if (ATTRIBUTE_AXIS.isEqual(tok->value)) {
|
||||
if (ATTRIBUTE_AXIS.Equals(tok->value)) {
|
||||
isAttr = MB_TRUE;
|
||||
}
|
||||
else if (!CHILD_AXIS.isEqual(tok->value)) {
|
||||
else if (!CHILD_AXIS.Equals(tok->value)) {
|
||||
// all done already for CHILD_AXIS, for all others
|
||||
// XXX report unexpected axis error
|
||||
return NS_ERROR_XPATH_PARSE_FAILED;
|
||||
|
|
|
@ -259,14 +259,14 @@ void txStandaloneXSLTProcessor::getHrefFromStylesheetPI(Document& xmlDocument,
|
|||
while (node) {
|
||||
if (node->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE) {
|
||||
String target = ((ProcessingInstruction*)node)->getTarget();
|
||||
if (STYLESHEET_PI.isEqual(target) ||
|
||||
STYLESHEET_PI_OLD.isEqual(target)) {
|
||||
if (STYLESHEET_PI.Equals(target) ||
|
||||
STYLESHEET_PI_OLD.Equals(target)) {
|
||||
String data = ((ProcessingInstruction*)node)->getData();
|
||||
type.clear();
|
||||
tmpHref.clear();
|
||||
type.Truncate();
|
||||
tmpHref.Truncate();
|
||||
parseStylesheetPI(data, type, tmpHref);
|
||||
if (XSL_MIME_TYPE.isEqual(type)) {
|
||||
href.clear();
|
||||
if (XSL_MIME_TYPE.Equals(type)) {
|
||||
href.Truncate();
|
||||
URIUtils::resolveHref(tmpHref, node->getBaseURI(), href);
|
||||
}
|
||||
}
|
||||
|
@ -283,32 +283,32 @@ void txStandaloneXSLTProcessor::parseStylesheetPI(String& data,
|
|||
String& type,
|
||||
String& href)
|
||||
{
|
||||
PRUint32 size = data.length();
|
||||
PRUint32 size = data.Length();
|
||||
NamedMap bufferMap;
|
||||
bufferMap.put(String("type"), &type);
|
||||
bufferMap.put(String("href"), &href);
|
||||
bufferMap.put(String(NS_LITERAL_STRING("type")), &type);
|
||||
bufferMap.put(String(NS_LITERAL_STRING("href")), &href);
|
||||
PRUint32 ccount = 0;
|
||||
MBool inLiteral = MB_FALSE;
|
||||
char matchQuote = '"';
|
||||
PRUnichar matchQuote = '"';
|
||||
String sink;
|
||||
String* buffer = &sink;
|
||||
|
||||
for (ccount = 0; ccount < size; ccount++) {
|
||||
char ch = data.charAt(ccount);
|
||||
PRUnichar ch = data.CharAt(ccount);
|
||||
switch ( ch ) {
|
||||
case ' ':
|
||||
if (inLiteral) {
|
||||
buffer->append(ch);
|
||||
buffer->Append(ch);
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
if (inLiteral) {
|
||||
buffer->append(ch);
|
||||
buffer->Append(ch);
|
||||
}
|
||||
else if (buffer->length() > 0) {
|
||||
else if (!buffer->IsEmpty()) {
|
||||
buffer = (String*)bufferMap.get(*buffer);
|
||||
if (!buffer) {
|
||||
sink.clear();
|
||||
sink.Truncate();
|
||||
buffer = &sink;
|
||||
}
|
||||
}
|
||||
|
@ -318,11 +318,11 @@ void txStandaloneXSLTProcessor::parseStylesheetPI(String& data,
|
|||
if (inLiteral) {
|
||||
if (matchQuote == ch) {
|
||||
inLiteral = MB_FALSE;
|
||||
sink.clear();
|
||||
sink.Truncate();
|
||||
buffer = &sink;
|
||||
}
|
||||
else {
|
||||
buffer->append(ch);
|
||||
buffer->Append(ch);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -331,7 +331,7 @@ void txStandaloneXSLTProcessor::parseStylesheetPI(String& data,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
buffer->append(ch);
|
||||
buffer->Append(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -342,8 +342,8 @@ txStandaloneXSLTProcessor::parsePath(const String& aPath, ErrorObserver& aErr)
|
|||
{
|
||||
ifstream xmlInput(NS_LossyConvertUCS2toASCII(aPath).get(), ios::in);
|
||||
if (!xmlInput) {
|
||||
String err("Couldn't open ");
|
||||
err.append(aPath);
|
||||
String err(NS_LITERAL_STRING("Couldn't open "));
|
||||
err.Append(aPath);
|
||||
aErr.receiveError(err);
|
||||
return 0;
|
||||
}
|
||||
|
@ -352,8 +352,8 @@ txStandaloneXSLTProcessor::parsePath(const String& aPath, ErrorObserver& aErr)
|
|||
Document* xmlDoc = xmlParser.parse(xmlInput, aPath);
|
||||
xmlInput.close();
|
||||
if (!xmlDoc) {
|
||||
String err("Parsing error in ");
|
||||
err.append(aPath);
|
||||
String err(NS_LITERAL_STRING("Parsing error in "));
|
||||
err.Append(aPath);
|
||||
aErr.receiveError(err);
|
||||
}
|
||||
return xmlDoc;
|
||||
|
|
|
@ -58,7 +58,7 @@ void txTextHandler::attribute(const String& aName,
|
|||
void txTextHandler::characters(const String& aData)
|
||||
{
|
||||
if (mLevel == 0)
|
||||
mValue.append(aData);
|
||||
mValue.Append(aData);
|
||||
}
|
||||
|
||||
void txTextHandler::comment(const String& aData)
|
||||
|
|
|
@ -180,7 +180,7 @@ void txUnknownHandler::startElement(const String& aName,
|
|||
rv = createHandlerAndFlush(format->mMethod, aName, aNsID);
|
||||
}
|
||||
else if (aNsID == kNameSpaceID_None &&
|
||||
aName.isEqualIgnoreCase(String("html"))) {
|
||||
aName.isEqualIgnoreCase(String(NS_LITERAL_STRING("html")))) {
|
||||
rv = createHandlerAndFlush(eHTMLOutput, aName, aNsID);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -99,7 +99,7 @@ void txXMLOutput::characters(const String& aData)
|
|||
if (mInCDATASection) {
|
||||
PRUint32 i = 0;
|
||||
PRUint32 j = 0;
|
||||
PRUint32 length = aData.length();
|
||||
PRUint32 length = aData.Length();
|
||||
|
||||
*mOut << CDATA_START;
|
||||
|
||||
|
@ -107,12 +107,12 @@ void txXMLOutput::characters(const String& aData)
|
|||
printUTF8Chars(aData);
|
||||
}
|
||||
else {
|
||||
mBuffer[j++] = aData.charAt(i++);
|
||||
mBuffer[j++] = aData.charAt(i++);
|
||||
mBuffer[j++] = aData.charAt(i++);
|
||||
mBuffer[j++] = aData.CharAt(i++);
|
||||
mBuffer[j++] = aData.CharAt(i++);
|
||||
mBuffer[j++] = aData.CharAt(i++);
|
||||
|
||||
while (i < length) {
|
||||
mBuffer[j++] = aData.charAt(i++);
|
||||
mBuffer[j++] = aData.CharAt(i++);
|
||||
if (mBuffer[(j - 1) % 4] == ']' &&
|
||||
mBuffer[j % 4] == ']' &&
|
||||
mBuffer[(j + 1) % 4] == '>') {
|
||||
|
@ -282,9 +282,9 @@ void txXMLOutput::closeStartTag(MBool aUseEmptyElementShorthand)
|
|||
}
|
||||
}
|
||||
|
||||
void txXMLOutput::printUTF8Char(DOM_CHAR& ch)
|
||||
void txXMLOutput::printUTF8Char(PRUnichar& ch)
|
||||
{
|
||||
// DOM_CHAR is 16-bits so we only need to cover up to 0xFFFF
|
||||
// PRUnichar is 16-bits so we only need to cover up to 0xFFFF
|
||||
|
||||
// 0x0000-0x007F
|
||||
if (ch < 128) {
|
||||
|
@ -305,11 +305,11 @@ void txXMLOutput::printUTF8Char(DOM_CHAR& ch)
|
|||
|
||||
void txXMLOutput::printUTF8Chars(const String& aData)
|
||||
{
|
||||
DOM_CHAR currChar;
|
||||
PRUnichar currChar;
|
||||
PRUint32 i = 0;
|
||||
|
||||
while (i < aData.length()) {
|
||||
currChar = aData.charAt(i++);
|
||||
while (i < aData.Length()) {
|
||||
currChar = aData.CharAt(i++);
|
||||
printUTF8Char(currChar);
|
||||
}
|
||||
}
|
||||
|
@ -317,14 +317,14 @@ void txXMLOutput::printUTF8Chars(const String& aData)
|
|||
void txXMLOutput::printWithXMLEntities(const String& aData,
|
||||
MBool aAttribute)
|
||||
{
|
||||
DOM_CHAR currChar;
|
||||
PRUnichar currChar;
|
||||
PRUint32 i;
|
||||
|
||||
if (&aData == &NULL_STRING)
|
||||
return;
|
||||
|
||||
for (i = 0; i < aData.length(); i++) {
|
||||
currChar = aData.charAt(i);
|
||||
for (i = 0; i < aData.Length(); i++) {
|
||||
currChar = aData.CharAt(i);
|
||||
switch (currChar) {
|
||||
case AMPERSAND:
|
||||
*mOut << AMP_ENTITY;
|
||||
|
|
|
@ -183,7 +183,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void closeStartTag(MBool aUseEmptyElementShorthand);
|
||||
void printUTF8Char(DOM_CHAR& ch);
|
||||
void printUTF8Char(PRUnichar& ch);
|
||||
void printUTF8Chars(const String& aData);
|
||||
void printWithXMLEntities(const String& aData, MBool aAttribute = MB_FALSE);
|
||||
|
||||
|
@ -199,7 +199,7 @@ protected:
|
|||
Stack mCDATASections;
|
||||
|
||||
private:
|
||||
DOM_CHAR mBuffer[4];
|
||||
PRUnichar mBuffer[4];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,7 +46,7 @@ nsresult txXSLTNumber::createNumber(Element* aNumberElement,
|
|||
ProcessorState* aPs,
|
||||
String& aResult)
|
||||
{
|
||||
aResult.clear();
|
||||
aResult.Truncate();
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Parse format
|
||||
|
@ -61,11 +61,11 @@ nsresult txXSLTNumber::createNumber(Element* aNumberElement,
|
|||
rv = getValueList(aNumberElement, aPs, values, valueString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (valueString.length()) {
|
||||
if (!valueString.IsEmpty()) {
|
||||
// XXX Xalan and XSLT2 says this, but XSLT1 says otherwise
|
||||
aResult = head;
|
||||
aResult.append(valueString);
|
||||
aResult.append(tail);
|
||||
aResult.Append(valueString);
|
||||
aResult.Append(tail);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -83,14 +83,14 @@ nsresult txXSLTNumber::createNumber(Element* aNumberElement,
|
|||
}
|
||||
|
||||
if (!first) {
|
||||
aResult.append(counter->mSeparator);
|
||||
aResult.Append(counter->mSeparator);
|
||||
}
|
||||
|
||||
counter->appendNumber(value, aResult);
|
||||
first = MB_FALSE;
|
||||
}
|
||||
|
||||
aResult.append(tail);
|
||||
aResult.Append(tail);
|
||||
|
||||
txListIterator iter(&counters);
|
||||
while (iter.hasNext()) {
|
||||
|
@ -104,7 +104,7 @@ nsresult txXSLTNumber::getValueList(Element* aNumberElement,
|
|||
ProcessorState* aPs, txList& aValues,
|
||||
String& aValueString)
|
||||
{
|
||||
aValueString.clear();
|
||||
aValueString.Truncate();
|
||||
|
||||
// If the value attribute exists then use that
|
||||
if (aNumberElement->hasAttr(txXSLTAtoms::value, kNameSpaceID_None)) {
|
||||
|
@ -316,7 +316,7 @@ nsresult txXSLTNumber::getValueList(Element* aNumberElement,
|
|||
}
|
||||
}
|
||||
else {
|
||||
aPs->receiveError(String("unknown value for format attribute"),
|
||||
aPs->receiveError(String(NS_LITERAL_STRING("unknown value for format attribute")),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -333,8 +333,8 @@ nsresult
|
|||
txXSLTNumber::getCounters(Element* aNumberElement, ProcessorState* aPs,
|
||||
txList& aCounters, String& aHead, String& aTail)
|
||||
{
|
||||
aHead.clear();
|
||||
aTail.clear();
|
||||
aHead.Truncate();
|
||||
aTail.Truncate();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -360,25 +360,25 @@ txXSLTNumber::getCounters(Element* aNumberElement, ProcessorState* aPs,
|
|||
formatAVT)) {
|
||||
aPs->processAttrValueTemplate(formatAVT, aNumberElement, format);
|
||||
}
|
||||
PRUint32 formatLen = format.length();
|
||||
PRUint32 formatLen = format.Length();
|
||||
PRUint32 formatPos = 0;
|
||||
UNICODE_CHAR ch = 0;
|
||||
PRUnichar ch = 0;
|
||||
|
||||
// start with header
|
||||
while (formatPos < formatLen &&
|
||||
!isAlphaNumeric(ch = format.charAt(formatPos))) {
|
||||
aHead.append(ch);
|
||||
!isAlphaNumeric(ch = format.CharAt(formatPos))) {
|
||||
aHead.Append(ch);
|
||||
++formatPos;
|
||||
}
|
||||
|
||||
// If there are no formatting tokens we need to create a default one.
|
||||
if (formatPos == formatLen) {
|
||||
txFormattedCounter* defaultCounter;
|
||||
rv = txFormattedCounter::getCounterFor(String("1"), groupSize,
|
||||
rv = txFormattedCounter::getCounterFor(String(NS_LITERAL_STRING("1")), groupSize,
|
||||
groupSeparator, defaultCounter);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
defaultCounter->mSeparator = String(".");
|
||||
defaultCounter->mSeparator = String(NS_LITERAL_STRING("."));
|
||||
rv = aCounters.add(defaultCounter);
|
||||
if (NS_FAILED(rv)) {
|
||||
// XXX ErrorReport: out of memory
|
||||
|
@ -397,12 +397,12 @@ txXSLTNumber::getCounters(Element* aNumberElement, ProcessorState* aPs,
|
|||
// there is only one formatting token and we're formatting a
|
||||
// value-list longer then one we use the default separator. This
|
||||
// won't be used when formatting the first value anyway.
|
||||
sepToken = String(".");
|
||||
sepToken = String(NS_LITERAL_STRING("."));
|
||||
}
|
||||
else {
|
||||
while (formatPos < formatLen &&
|
||||
!isAlphaNumeric(ch = format.charAt(formatPos))) {
|
||||
sepToken.append(ch);
|
||||
!isAlphaNumeric(ch = format.CharAt(formatPos))) {
|
||||
sepToken.Append(ch);
|
||||
++formatPos;
|
||||
}
|
||||
}
|
||||
|
@ -416,8 +416,8 @@ txXSLTNumber::getCounters(Element* aNumberElement, ProcessorState* aPs,
|
|||
// parse formatting token
|
||||
String numToken;
|
||||
while (formatPos < formatLen &&
|
||||
isAlphaNumeric(ch = format.charAt(formatPos))) {
|
||||
numToken.append(ch);
|
||||
isAlphaNumeric(ch = format.CharAt(formatPos))) {
|
||||
numToken.Append(ch);
|
||||
++formatPos;
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,7 @@ txXSLTNumber::getPrevInDocumentOrder(Node* aNode)
|
|||
#define TX_MATCH_CHAR(ch, a) if (ch < a) return MB_FALSE; \
|
||||
if (ch == a) return MB_TRUE
|
||||
|
||||
MBool txXSLTNumber::isAlphaNumeric(UNICODE_CHAR ch)
|
||||
MBool txXSLTNumber::isAlphaNumeric(PRUnichar ch)
|
||||
{
|
||||
TX_CHAR_RANGE(ch, 0x0030, 0x0039);
|
||||
TX_CHAR_RANGE(ch, 0x0041, 0x005A);
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
|
||||
static Node* getPrevInDocumentOrder(Node* aNode);
|
||||
|
||||
static MBool isAlphaNumeric(UNICODE_CHAR ch);
|
||||
static MBool isAlphaNumeric(PRUnichar ch);
|
||||
};
|
||||
|
||||
class txFormattedCounter {
|
||||
|
|
|
@ -59,14 +59,14 @@ private:
|
|||
|
||||
class txAlphaCounter : public txFormattedCounter {
|
||||
public:
|
||||
txAlphaCounter(UNICODE_CHAR aOffset) : mOffset(aOffset)
|
||||
txAlphaCounter(PRUnichar aOffset) : mOffset(aOffset)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void appendNumber(PRInt32 aNumber, String& aDest);
|
||||
|
||||
private:
|
||||
UNICODE_CHAR mOffset;
|
||||
PRUnichar mOffset;
|
||||
};
|
||||
|
||||
class txRomanCounter : public txFormattedCounter {
|
||||
|
@ -87,12 +87,12 @@ txFormattedCounter::getCounterFor(const String& aToken, PRInt32 aGroupSize,
|
|||
const String& aGroupSeparator,
|
||||
txFormattedCounter*& aCounter)
|
||||
{
|
||||
PRInt32 length = aToken.length();
|
||||
PRInt32 length = aToken.Length();
|
||||
NS_ASSERTION(length, "getting counter for empty token");
|
||||
aCounter = 0;
|
||||
|
||||
if (length == 1) {
|
||||
UNICODE_CHAR ch = aToken.charAt(0);
|
||||
PRUnichar ch = aToken.CharAt(0);
|
||||
switch (ch) {
|
||||
|
||||
case 'i':
|
||||
|
@ -117,10 +117,10 @@ txFormattedCounter::getCounterFor(const String& aToken, PRInt32 aGroupSize,
|
|||
// for now, the only multi-char token we support are decimals
|
||||
PRInt32 i;
|
||||
for (i = 0; i < length-1; ++i) {
|
||||
if (aToken.charAt(i) != '0')
|
||||
if (aToken.CharAt(i) != '0')
|
||||
break;
|
||||
}
|
||||
if (i == length-1 && aToken.charAt(i) == '1') {
|
||||
if (i == length-1 && aToken.CharAt(i) == '1') {
|
||||
aCounter = new txDecimalCounter(length, aGroupSize, aGroupSeparator);
|
||||
}
|
||||
else {
|
||||
|
@ -144,10 +144,8 @@ txDecimalCounter::txDecimalCounter(PRInt32 aMinLength, PRInt32 aGroupSize,
|
|||
|
||||
void txDecimalCounter::appendNumber(PRInt32 aNumber, String& aDest)
|
||||
{
|
||||
String num;
|
||||
|
||||
const PRInt32 bufsize = 10; //must be able to fit an PRInt32
|
||||
UNICODE_CHAR buf[bufsize];
|
||||
PRUnichar buf[bufsize];
|
||||
PRInt32 pos = bufsize;
|
||||
while (aNumber > 0) {
|
||||
PRInt32 ch = aNumber % 10;
|
||||
|
@ -167,26 +165,26 @@ void txDecimalCounter::appendNumber(PRInt32 aNumber, String& aDest)
|
|||
// pos will always be zero
|
||||
PRInt32 extraPos = mMinLength;
|
||||
while (extraPos > bufsize) {
|
||||
aDest.append('0');
|
||||
aDest.Append(PRUnichar('0'));
|
||||
--extraPos;
|
||||
if (extraPos % mGroupSize == 0) {
|
||||
aDest.append(mGroupSeparator);
|
||||
aDest.Append(mGroupSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
// copy string to buffer
|
||||
if (mGroupSize >= bufsize - pos) {
|
||||
// no grouping will occur
|
||||
aDest.append(buf + pos, (PRUint32)(bufsize - pos));
|
||||
aDest.Append(buf + pos, (PRUint32)(bufsize - pos));
|
||||
}
|
||||
else {
|
||||
// append chars up to first grouping separator
|
||||
PRInt32 len = ((bufsize - pos - 1) % mGroupSize) + 1;
|
||||
aDest.append(buf + pos, len);
|
||||
aDest.Append(buf + pos, len);
|
||||
pos += len;
|
||||
while (bufsize - pos > 0) {
|
||||
aDest.append(mGroupSeparator);
|
||||
aDest.append(buf + pos, mGroupSize);
|
||||
aDest.Append(mGroupSeparator);
|
||||
aDest.Append(buf + pos, mGroupSize);
|
||||
pos += mGroupSize;
|
||||
}
|
||||
NS_ASSERTION(bufsize == pos, "error while grouping");
|
||||
|
@ -196,9 +194,7 @@ void txDecimalCounter::appendNumber(PRInt32 aNumber, String& aDest)
|
|||
|
||||
void txAlphaCounter::appendNumber(PRInt32 aNumber, String& aDest)
|
||||
{
|
||||
String num;
|
||||
|
||||
UNICODE_CHAR buf[11];
|
||||
PRUnichar buf[11];
|
||||
buf[11] = 0;
|
||||
PRInt32 pos = 11;
|
||||
while (aNumber > 0) {
|
||||
|
@ -208,7 +204,7 @@ void txAlphaCounter::appendNumber(PRInt32 aNumber, String& aDest)
|
|||
buf[--pos] = ch + mOffset;
|
||||
}
|
||||
|
||||
aDest.append(buf + pos, (PRUint32)(11 - pos));
|
||||
aDest.Append(buf + pos, (PRUint32)(11 - pos));
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,7 +225,7 @@ void txRomanCounter::appendNumber(PRInt32 aNumber, String& aDest)
|
|||
}
|
||||
|
||||
while (aNumber >= 1000) {
|
||||
aDest.append(!mTableOffset ? 'm' : 'M');
|
||||
aDest.Append(!mTableOffset ? PRUnichar('m') : PRUnichar('M'));
|
||||
aNumber -= 1000;
|
||||
}
|
||||
|
||||
|
@ -238,14 +234,14 @@ void txRomanCounter::appendNumber(PRInt32 aNumber, String& aDest)
|
|||
// Hundreds
|
||||
posValue = aNumber / 100;
|
||||
aNumber %= 100;
|
||||
aDest.append(NS_ConvertASCIItoUCS2(kTxRomanNumbers[posValue +
|
||||
aDest.Append(NS_ConvertASCIItoUCS2(kTxRomanNumbers[posValue +
|
||||
mTableOffset]));
|
||||
// Tens
|
||||
posValue = aNumber / 10;
|
||||
aNumber %= 10;
|
||||
aDest.append(NS_ConvertASCIItoUCS2(kTxRomanNumbers[10 + posValue +
|
||||
aDest.Append(NS_ConvertASCIItoUCS2(kTxRomanNumbers[10 + posValue +
|
||||
mTableOffset]));
|
||||
// Ones
|
||||
aDest.append(NS_ConvertASCIItoUCS2(kTxRomanNumbers[20 + aNumber +
|
||||
aDest.Append(NS_ConvertASCIItoUCS2(kTxRomanNumbers[20 + aNumber +
|
||||
mTableOffset]));
|
||||
}
|
||||
|
|
|
@ -138,17 +138,17 @@ nsresult txUnionPattern::getSimplePatterns(txList& aList)
|
|||
void txUnionPattern::toString(String& aDest)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
aDest.append("txUnionPattern{");
|
||||
aDest.Append(NS_LITERAL_STRING("txUnionPattern{"));
|
||||
#endif
|
||||
txListIterator iter(&mLocPathPatterns);
|
||||
if (iter.hasNext())
|
||||
((txPattern*)iter.next())->toString(aDest);
|
||||
while (iter.hasNext()) {
|
||||
aDest.append(" | ");
|
||||
aDest.Append(NS_LITERAL_STRING(" | "));
|
||||
((txPattern*)iter.next())->toString(aDest);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
aDest.append("}");
|
||||
aDest.Append(PRUnichar('}'));
|
||||
#endif
|
||||
} // toString
|
||||
|
||||
|
@ -259,7 +259,7 @@ void txLocPathPattern::toString(String& aDest)
|
|||
{
|
||||
txListIterator iter(&mSteps);
|
||||
#ifdef DEBUG
|
||||
aDest.append("txLocPathPattern{");
|
||||
aDest.Append(NS_LITERAL_STRING("txLocPathPattern{"));
|
||||
#endif
|
||||
Step* step;
|
||||
step = (Step*)iter.next();
|
||||
|
@ -268,13 +268,13 @@ void txLocPathPattern::toString(String& aDest)
|
|||
}
|
||||
while ((step = (Step*)iter.next())) {
|
||||
if (step->isChild)
|
||||
aDest.append("/");
|
||||
aDest.Append(PRUnichar('/'));
|
||||
else
|
||||
aDest.append("//");
|
||||
aDest.Append(NS_LITERAL_STRING("//"));
|
||||
step->pattern->toString(aDest);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
aDest.append("}");
|
||||
aDest.Append(PRUnichar('}'));
|
||||
#endif
|
||||
} // txLocPathPattern::toString
|
||||
|
||||
|
@ -301,12 +301,12 @@ double txRootPattern::getDefaultPriority()
|
|||
void txRootPattern::toString(String& aDest)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
aDest.append("txRootPattern{");
|
||||
aDest.Append(NS_LITERAL_STRING("txRootPattern{"));
|
||||
#endif
|
||||
if (mSerialize)
|
||||
aDest.append("/");
|
||||
aDest.Append(PRUnichar('/'));
|
||||
#ifdef DEBUG
|
||||
aDest.append("}");
|
||||
aDest.Append(PRUnichar('}'));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -406,17 +406,17 @@ double txIdPattern::getDefaultPriority()
|
|||
void txIdPattern::toString(String& aDest)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
aDest.append("txIdPattern{");
|
||||
aDest.Append(NS_LITERAL_STRING("txIdPattern{"));
|
||||
#endif
|
||||
aDest.append("id('");
|
||||
aDest.Append(NS_LITERAL_STRING("id('"));
|
||||
#ifdef TX_EXE
|
||||
aDest.append(mIds);
|
||||
aDest.Append(mIds);
|
||||
#else
|
||||
aDest.getNSString().Append(mIds);
|
||||
#endif
|
||||
aDest.append("')");
|
||||
aDest.Append(NS_LITERAL_STRING("')"));
|
||||
#ifdef DEBUG
|
||||
aDest.append("}");
|
||||
aDest.Append(PRUnichar('}'));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -456,22 +456,22 @@ double txKeyPattern::getDefaultPriority()
|
|||
void txKeyPattern::toString(String& aDest)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
aDest.append("txKeyPattern{");
|
||||
aDest.Append(NS_LITERAL_STRING("txKeyPattern{"));
|
||||
#endif
|
||||
aDest.append("key('");
|
||||
aDest.Append(NS_LITERAL_STRING("key('"));
|
||||
String tmp;
|
||||
if (mPrefix) {
|
||||
TX_GET_ATOM_STRING(mPrefix, tmp);
|
||||
aDest.append(tmp);
|
||||
aDest.append(':');
|
||||
aDest.Append(tmp);
|
||||
aDest.Append(PRUnichar(':'));
|
||||
}
|
||||
TX_GET_ATOM_STRING(mName.mLocalName, tmp);
|
||||
aDest.append(tmp);
|
||||
aDest.append(", ");
|
||||
aDest.append(mValue);
|
||||
aDest.append("')");
|
||||
aDest.Append(tmp);
|
||||
aDest.Append(NS_LITERAL_STRING(", "));
|
||||
aDest.Append(mValue);
|
||||
aDest.Append(NS_LITERAL_STRING("')"));
|
||||
#ifdef DEBUG
|
||||
aDest.append("}");
|
||||
aDest.Append(PRUnichar('}'));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -606,15 +606,15 @@ double txStepPattern::getDefaultPriority()
|
|||
void txStepPattern::toString(String& aDest)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
aDest.append("txStepPattern{");
|
||||
aDest.Append(NS_LITERAL_STRING("txStepPattern{"));
|
||||
#endif
|
||||
if (mIsAttr)
|
||||
aDest.append("@");
|
||||
aDest.Append(PRUnichar('@'));
|
||||
if (mNodeTest)
|
||||
mNodeTest->toString(aDest);
|
||||
|
||||
PredicateList::toString(aDest);
|
||||
#ifdef DEBUG
|
||||
aDest.append("}");
|
||||
aDest.Append(PRUnichar('}'));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
* Sorts Nodes as specified by the W3C XSLT 1.0 Recommendation
|
||||
*/
|
||||
|
||||
#define DEFAULT_LANG "en"
|
||||
#define DEFAULT_LANG NS_LITERAL_STRING("en")
|
||||
|
||||
txNodeSorter::txNodeSorter(ProcessorState* aPs) : mPs(aPs),
|
||||
mNKeys(0),
|
||||
|
@ -99,10 +99,10 @@ MBool txNodeSorter::addSortElement(Element* aSortElement)
|
|||
// Order
|
||||
MBool ascending;
|
||||
MBool hasAttr = getAttrAsAVT(aSortElement, txXSLTAtoms::order, attrValue);
|
||||
if (!hasAttr || attrValue.isEqual(ASCENDING_VALUE)) {
|
||||
if (!hasAttr || attrValue.Equals(ASCENDING_VALUE)) {
|
||||
ascending = MB_TRUE;
|
||||
}
|
||||
else if (attrValue.isEqual(DESCENDING_VALUE)) {
|
||||
else if (attrValue.Equals(DESCENDING_VALUE)) {
|
||||
ascending = MB_FALSE;
|
||||
}
|
||||
else {
|
||||
|
@ -115,21 +115,21 @@ MBool txNodeSorter::addSortElement(Element* aSortElement)
|
|||
// Create comparator depending on datatype
|
||||
String dataType;
|
||||
hasAttr = getAttrAsAVT(aSortElement, txXSLTAtoms::dataType, dataType);
|
||||
if (!hasAttr || dataType.isEqual(TEXT_VALUE)) {
|
||||
if (!hasAttr || dataType.Equals(TEXT_VALUE)) {
|
||||
// Text comparator
|
||||
|
||||
// Language
|
||||
String lang;
|
||||
if (!getAttrAsAVT(aSortElement, txXSLTAtoms::lang, lang))
|
||||
lang.append(DEFAULT_LANG);
|
||||
lang.Append(DEFAULT_LANG);
|
||||
|
||||
// Case-order
|
||||
MBool upperFirst;
|
||||
hasAttr = getAttrAsAVT(aSortElement, txXSLTAtoms::caseOrder, attrValue);
|
||||
if (!hasAttr || attrValue.isEqual(UPPER_FIRST_VALUE)) {
|
||||
if (!hasAttr || attrValue.Equals(UPPER_FIRST_VALUE)) {
|
||||
upperFirst = MB_TRUE;
|
||||
}
|
||||
else if (attrValue.isEqual(LOWER_FIRST_VALUE)) {
|
||||
else if (attrValue.Equals(LOWER_FIRST_VALUE)) {
|
||||
upperFirst = MB_FALSE;
|
||||
}
|
||||
else {
|
||||
|
@ -142,7 +142,7 @@ MBool txNodeSorter::addSortElement(Element* aSortElement)
|
|||
upperFirst,
|
||||
lang);
|
||||
}
|
||||
else if (dataType.isEqual(NUMBER_VALUE)) {
|
||||
else if (dataType.Equals(NUMBER_VALUE)) {
|
||||
// Number comparator
|
||||
key->mComparator = new txResultNumberComparator(ascending);
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ MBool txNodeSorter::getAttrAsAVT(Element* aSortElement,
|
|||
txAtom* aAttrName,
|
||||
String& aResult)
|
||||
{
|
||||
aResult.clear();
|
||||
aResult.Truncate();
|
||||
|
||||
String attValue;
|
||||
if (!aSortElement->getAttr(aAttrName, kNameSpaceID_None, attValue))
|
||||
|
|
|
@ -144,14 +144,14 @@ int txResultStringComparator::compareValues(TxObject* aVal1, TxObject* aVal2)
|
|||
StringValue* strval1 = (StringValue*)aVal1;
|
||||
StringValue* strval2 = (StringValue*)aVal2;
|
||||
#ifdef TX_EXE
|
||||
PRUint32 len1 = strval1->mStr.length();
|
||||
PRUint32 len2 = strval2->mStr.length();
|
||||
PRUint32 len1 = strval1->mStr.Length();
|
||||
PRUint32 len2 = strval2->mStr.Length();
|
||||
PRUint32 minLength = (len1 < len2) ? len1 : len2;
|
||||
|
||||
PRUint32 c = 0;
|
||||
while (c < minLength) {
|
||||
UNICODE_CHAR ch1 = strval1->mStr.charAt(c);
|
||||
UNICODE_CHAR ch2 = strval2->mStr.charAt(c);
|
||||
PRUnichar ch1 = strval1->mStr.CharAt(c);
|
||||
PRUnichar ch2 = strval2->mStr.CharAt(c);
|
||||
if (ch1 < ch2)
|
||||
return ((mSorting & kAscending) ? 1 : -1) * -1;
|
||||
if (ch2 < ch1)
|
||||
|
|
Загрузка…
Ссылка в новой задаче