зеркало из https://github.com/mozilla/pjs.git
Fix for bug 146967 (Clean up Transformiix strings). r=Pike, sr=jst.
This commit is contained in:
Родитель
f3c2d92ed8
Коммит
8bf305a18f
|
@ -65,7 +65,6 @@ LOBJS =../source/base/ArrayList.$(OBJ_SUFFIX) \
|
|||
../source/base/Tokenizer.$(OBJ_SUFFIX) \
|
||||
../source/base/txAtoms.$(OBJ_SUFFIX) \
|
||||
../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||
../source/base/MozillaString.$(OBJ_SUFFIX) \
|
||||
../source/base/txURIUtils.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaObjectWrapper.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaAttr.$(OBJ_SUFFIX) \
|
||||
|
|
|
@ -50,7 +50,6 @@ CPP_OBJS= \
|
|||
..\source\base\$(OBJDIR)\Tokenizer.obj \
|
||||
..\source\base\$(OBJDIR)\txAtoms.obj \
|
||||
..\source\base\$(OBJDIR)\txExpandedNameMap.obj \
|
||||
..\source\base\$(OBJDIR)\MozillaString.obj \
|
||||
..\source\base\$(OBJDIR)\txURIUtils.obj \
|
||||
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaObjectWrapper.obj \
|
||||
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaAttr.obj \
|
||||
|
|
|
@ -1121,13 +1121,6 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MozillaString.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>XMLUtils.cpp</PATH>
|
||||
|
@ -2045,11 +2038,6 @@
|
|||
<PATH>MozillaNotation.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MozillaString.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>XMLParser.cpp</PATH>
|
||||
|
@ -3219,13 +3207,6 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MozillaString.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>XMLUtils.cpp</PATH>
|
||||
|
@ -4159,11 +4140,6 @@
|
|||
<PATH>MozillaNotation.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MozillaString.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>NSPR20.shlb</PATH>
|
||||
|
@ -4395,12 +4371,6 @@
|
|||
<PATH>Map.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>transformiixDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>MozillaString.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>transformiixDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
|
|
|
@ -47,7 +47,7 @@ void CommandLineUtils::getOptions
|
|||
//-- check full flag, otherwise try to find
|
||||
//-- flag within string
|
||||
if (!flags.contains(flag)) {
|
||||
PRInt32 idx = 1;
|
||||
PRUint32 idx = 1;
|
||||
String tmpFlag;
|
||||
while(idx <= flag.length()) {
|
||||
flag.subString(0,idx, tmpFlag);
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
*/
|
||||
|
||||
#include "primitives.h"
|
||||
#include "XMLUtils.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef WIN32
|
||||
|
@ -130,17 +131,15 @@ MBool Double::isNeg(double aDbl)
|
|||
*/
|
||||
double Double::toDouble(const String& aSrc)
|
||||
{
|
||||
PRInt32 idx = 0;
|
||||
PRInt32 len = aSrc.length();
|
||||
PRUint32 idx = 0;
|
||||
PRUint32 len = aSrc.length();
|
||||
MBool digitFound = MB_FALSE;
|
||||
|
||||
// leading whitespace
|
||||
while (idx < len &&
|
||||
(aSrc.charAt(idx) == ' ' ||
|
||||
aSrc.charAt(idx) == '\n' ||
|
||||
aSrc.charAt(idx) == '\r' ||
|
||||
aSrc.charAt(idx) == '\t'))
|
||||
XMLUtils::isWhitespace(aSrc.charAt(idx))) {
|
||||
++idx;
|
||||
}
|
||||
|
||||
// sign char
|
||||
if (idx < len && aSrc.charAt(idx) == '-')
|
||||
|
@ -168,12 +167,10 @@ double Double::toDouble(const String& aSrc)
|
|||
}
|
||||
|
||||
// ending whitespace
|
||||
while ((aSrc.charAt(idx) == ' ' ||
|
||||
aSrc.charAt(idx) == '\n' ||
|
||||
aSrc.charAt(idx) == '\r' ||
|
||||
aSrc.charAt(idx) == '\t') &&
|
||||
idx < len)
|
||||
while (idx < len &&
|
||||
XMLUtils::isWhitespace(aSrc.charAt(idx))) {
|
||||
++idx;
|
||||
}
|
||||
|
||||
// "."==NaN, ".0"=="0."==0
|
||||
if (digitFound && idx == len) {
|
||||
|
|
|
@ -54,8 +54,6 @@ CPPSRCS = ArrayList.cpp \
|
|||
ifdef TX_EXE
|
||||
CPPSRCS += CommandLineUtils.cpp \
|
||||
TxString.cpp
|
||||
else
|
||||
CPPSRCS += MozillaString.cpp
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -143,15 +143,6 @@ void NamedMap::dumpMap() {
|
|||
#endif
|
||||
} //-- dumpMap
|
||||
|
||||
/**
|
||||
* Returns the object reference in this Map associated with the given name
|
||||
* @return the object reference in this Map associated with the given name
|
||||
**/
|
||||
TxObject* NamedMap::get(const char* key) {
|
||||
String sKey = key;
|
||||
return get(sKey);
|
||||
} //-- get
|
||||
|
||||
/**
|
||||
* Returns the object reference in this Map associated with the given name
|
||||
* @return the object reference in this Map associated with the given name
|
||||
|
@ -190,15 +181,6 @@ StringList* NamedMap::keys() {
|
|||
return list;
|
||||
} //-- keys
|
||||
|
||||
/**
|
||||
* Adds the specified Node to the top of this Stack.
|
||||
* @param node the Node to add to the top of the Stack
|
||||
**/
|
||||
void NamedMap::put(const char* key, TxObject* obj) {
|
||||
String sKey = key;
|
||||
put(sKey, obj);
|
||||
} //-- put
|
||||
|
||||
/**
|
||||
* Adds the specified Node to the top of this Stack.
|
||||
* @param node the Node to add to the top of the Stack
|
||||
|
@ -333,17 +315,14 @@ NamedMap::BucketItem* NamedMap::getBucketItem(const String& key) {
|
|||
|
||||
/**
|
||||
**/
|
||||
unsigned long NamedMap::hashKey(const String& key) {
|
||||
|
||||
PRInt32 len = key.length();
|
||||
UNICODE_CHAR* chars = new UNICODE_CHAR[len];
|
||||
key.toUnicode(chars);
|
||||
unsigned long NamedMap::hashKey(const String& key)
|
||||
{
|
||||
PRUint32 len = key.length();
|
||||
|
||||
unsigned long hashCode = 0;
|
||||
for (PRInt32 i = 0; i < len; i++) {
|
||||
hashCode += ((PRInt32)chars[i]) << 3;
|
||||
for (PRUint32 i = 0; i < len; ++i) {
|
||||
hashCode += ((PRInt32)key.charAt(i)) << 3;
|
||||
}
|
||||
delete [] chars;
|
||||
return hashCode;
|
||||
} //-- hashKey
|
||||
|
||||
|
|
|
@ -73,22 +73,11 @@ public:
|
|||
**/
|
||||
TxObject* get(const String& name);
|
||||
|
||||
/**
|
||||
* Returns the object reference in this Map associated with the given name
|
||||
* @return the object reference in this Map associated with the given name
|
||||
**/
|
||||
TxObject* get(const char* name);
|
||||
|
||||
/**
|
||||
* Adds the Object reference to the map and associates it with the given name
|
||||
**/
|
||||
void put(const String& name, TxObject* obj);
|
||||
|
||||
/**
|
||||
* Adds the Object reference to the map and associates it with the given name
|
||||
**/
|
||||
void put(const char* name, TxObject* obj);
|
||||
|
||||
/**
|
||||
* Removes all elements from the Map table
|
||||
**/
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
*/
|
||||
|
||||
#include "Tokenizer.h"
|
||||
#include "XMLUtils.h"
|
||||
|
||||
/*
|
||||
* Creates a new Tokenizer using the given source string
|
||||
|
@ -67,10 +68,8 @@ txTokenizer::txTokenizer(const String& aSource)
|
|||
|
||||
// Advance to start pos
|
||||
while (mCurrentPos < mSize) {
|
||||
UNICODE_CHAR ch = mSource.charAt(mCurrentPos);
|
||||
// If character is not a whitespace, we are at start of first token
|
||||
if (ch != ' ' && ch != '\n' &&
|
||||
ch != '\r' && ch != '\t')
|
||||
if (!XMLUtils::isWhitespace(mSource.charAt(mCurrentPos)))
|
||||
break;
|
||||
++mCurrentPos;
|
||||
}
|
||||
|
@ -87,18 +86,15 @@ void txTokenizer::nextToken(String& aBuffer)
|
|||
while (mCurrentPos < mSize) {
|
||||
UNICODE_CHAR ch = mSource.charAt(mCurrentPos++);
|
||||
// If character is not a delimiter we append it
|
||||
if (ch == ' ' || ch == '\n' ||
|
||||
ch == '\r' || ch == '\t')
|
||||
if (XMLUtils::isWhitespace(ch))
|
||||
break;
|
||||
aBuffer.append(ch);
|
||||
}
|
||||
|
||||
// Advance to next start pos
|
||||
while (mCurrentPos < mSize) {
|
||||
UNICODE_CHAR ch = mSource.charAt(mCurrentPos);
|
||||
// If character is not a whitespace, we are at start of next token
|
||||
if (ch != ' ' && ch != '\n' &&
|
||||
ch != '\r' && ch != '\t')
|
||||
if (!XMLUtils::isWhitespace(mSource.charAt(mCurrentPos)))
|
||||
break;
|
||||
++mCurrentPos;
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
PRInt32 mCurrentPos;
|
||||
PRInt32 mSize;
|
||||
PRUint32 mCurrentPos;
|
||||
PRUint32 mSize;
|
||||
String mSource;
|
||||
|
||||
};
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -25,186 +25,224 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef MITRE_STRING
|
||||
#define MITRE_STRING
|
||||
#ifndef txString_h__
|
||||
#define txString_h__
|
||||
|
||||
#include "TxObject.h"
|
||||
#include "baseutils.h"
|
||||
#include <iostream.h>
|
||||
|
||||
#ifdef TX_EXE
|
||||
#include <iostream.h>
|
||||
typedef unsigned short UNICODE_CHAR;
|
||||
const PRInt32 kNotFound = -1;
|
||||
#else
|
||||
#include "nsString.h"
|
||||
typedef PRUnichar UNICODE_CHAR;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
class String
|
||||
#ifdef TX_EXE
|
||||
: public TxObject
|
||||
#endif
|
||||
|
||||
#define NOT_FOUND -1
|
||||
|
||||
class String : public TxObject
|
||||
{
|
||||
//Translate UNICODE_CHARs to Chars and output to the provided stream
|
||||
friend ostream& operator<<(ostream& output, const String& source);
|
||||
public:
|
||||
/*
|
||||
* Default constructor.
|
||||
*/
|
||||
String();
|
||||
|
||||
public:
|
||||
String(); //Default Constructor, create an empty string
|
||||
String(PRInt32 initSize); //Create an empty string of a specific size
|
||||
String(const String& source); //Create a copy of the source string
|
||||
String(const char* source); //Create a string from the characters
|
||||
String(const UNICODE_CHAR* source);
|
||||
String(const UNICODE_CHAR* source, PRInt32 length);
|
||||
#ifndef TX_EXE
|
||||
String(nsString* theNSString);
|
||||
#ifdef TX_EXE
|
||||
/*
|
||||
* Copying constructor.
|
||||
*/
|
||||
String(const String& aSource);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
#else
|
||||
explicit String(const nsAString& aSource);
|
||||
#endif
|
||||
~String();
|
||||
|
||||
~String(); //Destroy the string, and free memory
|
||||
/*
|
||||
* Append aSource to this string.
|
||||
*/
|
||||
void append(UNICODE_CHAR aSource);
|
||||
void append(const String& aSource);
|
||||
|
||||
/*
|
||||
* Insert aSource at aOffset in this string.
|
||||
*/
|
||||
void insert(PRUint32 aOffset, UNICODE_CHAR aSource);
|
||||
void insert(PRUint32 aOffset, const String& aSource);
|
||||
|
||||
//Assign source to this string
|
||||
virtual String& operator=(const String& source);
|
||||
virtual String& operator=(const char* source);
|
||||
virtual String& operator=(const UNICODE_CHAR* source);
|
||||
virtual String& operator=(PRInt32 source);
|
||||
/*
|
||||
* Replace characters starting at aOffset with aSource.
|
||||
*/
|
||||
void replace(PRUint32 aOffset, UNICODE_CHAR aSource);
|
||||
void replace(PRUint32 aOffset, const String& aSource);
|
||||
|
||||
//Grow buffer if necessary and append the source
|
||||
virtual void append(UNICODE_CHAR source);
|
||||
virtual void append(char source);
|
||||
virtual void append(const String& source);
|
||||
virtual void append(const char* source);
|
||||
virtual void append(const UNICODE_CHAR* source);
|
||||
virtual void append(const UNICODE_CHAR* source, PRInt32 length);
|
||||
virtual void append(PRInt32 source);
|
||||
/*
|
||||
* Delete aCount characters starting at aOffset.
|
||||
*/
|
||||
void deleteChars(PRUint32 aOffset, PRUint32 aCount);
|
||||
|
||||
//Provide the ability to insert data into the middle of a string
|
||||
virtual void insert(PRInt32 offset, const UNICODE_CHAR source);
|
||||
virtual void insert(PRInt32 offset, const char source);
|
||||
virtual void insert(PRInt32 offset, const String& source);
|
||||
virtual void insert(PRInt32 offset, const char* source);
|
||||
virtual void insert(PRInt32 offset, const UNICODE_CHAR* source);
|
||||
virtual void insert(PRInt32 offset, const UNICODE_CHAR* source,
|
||||
PRInt32 sourceLength);
|
||||
virtual void insert(PRInt32 offset, PRInt32 source);
|
||||
/*
|
||||
* Returns the character at aIndex. Caller needs to check the
|
||||
* index for out-of-bounds errors.
|
||||
*/
|
||||
UNICODE_CHAR charAt(PRUint32 aIndex) const;
|
||||
|
||||
//Provide the ability to replace one or more characters
|
||||
virtual void replace(PRInt32 offset, const UNICODE_CHAR source);
|
||||
virtual void replace(PRInt32 offset, const char source);
|
||||
virtual void replace(PRInt32 offset, const String& source);
|
||||
virtual void replace(PRInt32 offset, const char* source);
|
||||
virtual void replace(PRInt32 offset, const UNICODE_CHAR* source);
|
||||
virtual void replace(PRInt32 offset, const UNICODE_CHAR* source,
|
||||
PRInt32 srcLength);
|
||||
virtual void replace(PRInt32 offset, PRInt32 source);
|
||||
/*
|
||||
* Clear the string.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
//Provide the ability to delete a range of charactes
|
||||
virtual void deleteChars(PRInt32 offset, PRInt32 count);
|
||||
/*
|
||||
* 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 the character at index.
|
||||
* If the index is out of bounds, -1 will be returned.
|
||||
**/
|
||||
virtual UNICODE_CHAR charAt(PRInt32 index) const;
|
||||
/*
|
||||
* Returns index of last occurrence of aData.
|
||||
*/
|
||||
PRInt32 lastIndexOf(UNICODE_CHAR aData,
|
||||
PRInt32 aOffset = 0) const;
|
||||
|
||||
virtual void clear(); //Clear string
|
||||
/*
|
||||
* Check equality between strings.
|
||||
*/
|
||||
MBool isEqual(const String& aData) const;
|
||||
|
||||
virtual void ensureCapacity(PRInt32 capacity); //Make sure buffer is at least
|
||||
//'size'
|
||||
/*
|
||||
* Check equality (ignoring case) between strings.
|
||||
*/
|
||||
MBool isEqualIgnoreCase(const String& aData) const;
|
||||
|
||||
//Returns index of first occurrence of data
|
||||
virtual PRInt32 indexOf(UNICODE_CHAR data) const;
|
||||
virtual PRInt32 indexOf(UNICODE_CHAR data, PRInt32 offset) const;
|
||||
virtual PRInt32 indexOf(const String& data) const;
|
||||
virtual PRInt32 indexOf(const String& data, PRInt32 offset) const;
|
||||
/*
|
||||
* Check whether the string is empty.
|
||||
*/
|
||||
MBool isEmpty() const;
|
||||
|
||||
virtual MBool isEqual(const String& data) const; //Check equality between
|
||||
//strings
|
||||
virtual MBool isEqualIgnoreCase(const String& data) const;
|
||||
/*
|
||||
* Return the length of the string.
|
||||
*/
|
||||
PRUint32 length() const;
|
||||
|
||||
//Returns index of last occurrence of data
|
||||
virtual PRInt32 lastIndexOf(UNICODE_CHAR data) const;
|
||||
virtual PRInt32 lastIndexOf(UNICODE_CHAR data, PRInt32 offset) const;
|
||||
virtual PRInt32 lastIndexOf(const String& data) const;
|
||||
virtual PRInt32 lastIndexOf(const String& data, PRInt32 offset) const;
|
||||
|
||||
//Checks whether the string is empty
|
||||
virtual MBool isEmpty() const;
|
||||
|
||||
virtual PRInt32 length() const; //Returns the length
|
||||
|
||||
/**
|
||||
* Sets the Length of this String, if length is less than 0, it will
|
||||
* be set to 0; if length > current length, the string will be extended
|
||||
* and padded with '\0' null characters. Otherwise the String
|
||||
* will be truncated
|
||||
**/
|
||||
virtual void setLength(PRInt32 length);
|
||||
|
||||
/**
|
||||
* Sets the Length of this String, if length is less than 0, it will
|
||||
* be set to 0; if length > current length, the string will be extended
|
||||
* and padded with given pad character. Otherwise the String
|
||||
* will be truncated
|
||||
**/
|
||||
virtual void setLength(PRInt32 length, UNICODE_CHAR padChar);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns a substring starting at start
|
||||
* Note: the dest String is cleared before use
|
||||
**/
|
||||
virtual String& subString(PRInt32 start, String& dest) const;
|
||||
*/
|
||||
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
|
||||
**/
|
||||
virtual String& subString(PRInt32 start, PRInt32 end, String& dest) const;
|
||||
*/
|
||||
String& subString(PRUint32 aStart, PRUint32 aEnd,
|
||||
String& aDest) const;
|
||||
|
||||
//Convert the internal rep. to a char buffer
|
||||
virtual char* toCharArray() const;
|
||||
virtual char* toCharArray(char* dest) const;
|
||||
virtual UNICODE_CHAR* toUnicode(UNICODE_CHAR* dest) const;
|
||||
virtual const UNICODE_CHAR* toUnicode() const;
|
||||
/*
|
||||
* Convert string to lowercase.
|
||||
*/
|
||||
void toLowerCase();
|
||||
|
||||
virtual void toLowerCase(); //Convert string to lowercase
|
||||
virtual void toUpperCase(); //Convert string to uppercase
|
||||
virtual void trim(); //Trim whitespace from both ends
|
||||
/*
|
||||
* Convert string to uppercase.
|
||||
*/
|
||||
void toUpperCase();
|
||||
|
||||
virtual void reverse(); //Reverse the string
|
||||
/*
|
||||
* Shorten the string to aLength.
|
||||
*/
|
||||
void truncate(PRUint32 aLength);
|
||||
|
||||
#ifndef TX_EXE
|
||||
virtual nsString& getNSString();
|
||||
virtual const nsString& getConstNSString() const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
//Convert an Int into a String
|
||||
//TK 12/09/1999 - Make this function available to Derrived classes
|
||||
String& ConvertInt(PRInt32 value, String& target);
|
||||
|
||||
//Calculates the length of a null terminated UNICODE_CHAR array
|
||||
PRInt32 UnicodeLength(const UNICODE_CHAR* data);
|
||||
|
||||
private:
|
||||
#ifndef TX_EXE
|
||||
nsString* ptrNSString;
|
||||
#ifdef TX_EXE
|
||||
/*
|
||||
* Assignment operator. Override default assignment operator
|
||||
* only on standalone, the default will do the right thing for
|
||||
* module.
|
||||
*/
|
||||
String& operator = (const String& aSource);
|
||||
#else
|
||||
PRInt32 strLength;
|
||||
PRInt32 bufferLength;
|
||||
UNICODE_CHAR* strBuffer;
|
||||
/*
|
||||
* Return a reference to this string's nsString.
|
||||
*/
|
||||
nsString& getNSString();
|
||||
|
||||
/*
|
||||
* Return a const reference to this string's nsString.
|
||||
*/
|
||||
const nsString& getConstNSString() const;
|
||||
#endif
|
||||
|
||||
//String copies itself to the destination
|
||||
void copyString(UNICODE_CHAR* dest);
|
||||
private:
|
||||
#ifndef TX_EXE
|
||||
nsString mString;
|
||||
#else
|
||||
/*
|
||||
* Make sure the string buffer can hold aCapacity characters.
|
||||
*/
|
||||
MBool ensureCapacity(PRUint32 aCapacity);
|
||||
|
||||
//Compare the two string representations for equality
|
||||
MBool isEqual(const UNICODE_CHAR* data, const UNICODE_CHAR* search,
|
||||
PRInt32 length) const;
|
||||
/*
|
||||
* Allocate a new UNICODE_CHAR buffer and copy this string's
|
||||
* buffer into it. Caller needs to free the buffer.
|
||||
*/
|
||||
UNICODE_CHAR* toUnicode() const;
|
||||
|
||||
/*
|
||||
* Compute the unicode length of aData.
|
||||
*/
|
||||
static PRUint32 unicodeLength(const UNICODE_CHAR* aData);
|
||||
|
||||
/*
|
||||
* Translate UNICODE_CHARs to Chars and output to the provided stream.
|
||||
*/
|
||||
friend ostream& operator << (ostream& aOutput, const String& aSource);
|
||||
|
||||
UNICODE_CHAR* mBuffer;
|
||||
PRUint32 mBufferLength;
|
||||
PRUint32 mLength;
|
||||
#endif
|
||||
|
||||
// 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;
|
||||
char* toCharArray() const;
|
||||
// XXX DEPRECATED
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream& output, const String& source);
|
||||
#ifdef TX_EXE
|
||||
ostream& operator << (ostream& aOutput, const String& aSource);
|
||||
|
||||
inline UNICODE_CHAR String::charAt(PRUint32 aIndex) const
|
||||
{
|
||||
NS_ASSERTION(aIndex < mLength, "|charAt| out-of-range");
|
||||
return mBuffer[aIndex];
|
||||
}
|
||||
|
||||
inline MBool String::isEmpty() const
|
||||
{
|
||||
return (mLength == 0);
|
||||
}
|
||||
|
||||
inline PRUint32 String::length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
#else
|
||||
// txMozillaString.h contains all inline implementations for the
|
||||
// Mozilla module.
|
||||
#include "txMozillaString.h"
|
||||
#endif
|
||||
|
||||
#endif // txString_h__
|
||||
|
|
|
@ -66,5 +66,9 @@
|
|||
#define MB_FALSE PR_FALSE
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -48,17 +48,13 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\Tokenizer.obj \
|
||||
.\$(OBJDIR)\txAtoms.obj \
|
||||
.\$(OBJDIR)\txExpandedNameMap.obj \
|
||||
.\$(OBJDIR)\txURIUtils.obj
|
||||
$(NULL)
|
||||
|
||||
!ifndef TX_EXE
|
||||
CPP_OBJS = $(CPP_OBJS) \
|
||||
.\$(OBJDIR)\MozillaString.obj \
|
||||
$(NULL)
|
||||
!else
|
||||
CPP_OBJS = $(CPP_OBJS) \
|
||||
!ifdef TX_EXE
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\CommandLineUtils.obj \
|
||||
.\$(OBJDIR)\TxString.obj \
|
||||
$(NULL)
|
||||
.\$(OBJDIR)\TxString.obj \
|
||||
$(CPP_OBJS)
|
||||
!endif
|
||||
|
||||
EXPORTS = \
|
||||
|
|
|
@ -0,0 +1,231 @@
|
|||
/* -*- 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"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(String)
|
||||
|
||||
inline String::String()
|
||||
{
|
||||
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::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, nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
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() - aStart;
|
||||
if (length < 0) {
|
||||
aDest.clear();
|
||||
}
|
||||
else {
|
||||
aDest.mString.Assign(Substring(mString, aStart, length));
|
||||
}
|
||||
return aDest;
|
||||
}
|
||||
|
||||
inline String& String::subString(PRUint32 aStart, PRUint32 aEnd,
|
||||
String& aDest) const
|
||||
{
|
||||
PRUint32 length = aEnd - aStart;
|
||||
if (length < 0) {
|
||||
aDest.clear();
|
||||
}
|
||||
else {
|
||||
aDest.mString.Assign(Substring(mString, aStart, length));
|
||||
}
|
||||
return aDest;
|
||||
}
|
||||
|
||||
inline void String::toLowerCase()
|
||||
{
|
||||
ToLowerCase(mString);
|
||||
}
|
||||
|
||||
inline void String::toUpperCase()
|
||||
{
|
||||
ToUpperCase(mString);
|
||||
}
|
||||
|
||||
inline nsString& String::getNSString()
|
||||
{
|
||||
return mString;
|
||||
}
|
||||
|
||||
inline const nsString& String::getConstNSString() 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 char* String::toCharArray() const
|
||||
{
|
||||
return ToNewCString(mString);
|
||||
}
|
||||
|
||||
#endif // txMozillaString_h__
|
|
@ -186,7 +186,7 @@ void URIUtils::resolveHref(const String& href, const String& base,
|
|||
void URIUtils::getFragmentIdentifier(const String& href, String& frag) {
|
||||
PRInt32 pos;
|
||||
pos = href.lastIndexOf('#');
|
||||
if(pos != NOT_FOUND)
|
||||
if(pos != kNotFound)
|
||||
href.subString(pos+1, frag);
|
||||
else
|
||||
frag.clear();
|
||||
|
@ -195,7 +195,7 @@ void URIUtils::getFragmentIdentifier(const String& href, String& frag) {
|
|||
void URIUtils::getDocumentURI(const String& href, String& docUri) {
|
||||
PRInt32 pos;
|
||||
pos = href.lastIndexOf('#');
|
||||
if(pos != NOT_FOUND)
|
||||
if(pos != kNotFound)
|
||||
href.subString(0,pos,docUri);
|
||||
else
|
||||
docUri = href;
|
||||
|
|
|
@ -77,42 +77,43 @@ int main(int argc, char** argv) {
|
|||
options.setObjectDeletion(MB_TRUE);
|
||||
CommandLineUtils::getOptions(options, argc, argv, flags);
|
||||
|
||||
if (!options.get("q")) {
|
||||
if (!options.get(String("q"))) {
|
||||
String copyright("(C) 1999 The MITRE Corporation, Keith Visco, and contributors");
|
||||
cerr << xsltProcessor.getAppName() << " ";
|
||||
cerr << xsltProcessor.getAppVersion() << endl;
|
||||
cerr << copyright << endl;
|
||||
//-- print banner line
|
||||
PRInt32 fillSize = copyright.length() + 1;
|
||||
String fill;
|
||||
fill.setLength(fillSize, '-');
|
||||
cerr << fill << endl << endl;
|
||||
PRUint32 fillSize = copyright.length() + 1;
|
||||
PRUint32 counter;
|
||||
for (counter = 0; counter < fillSize; ++counter)
|
||||
cerr << '-';
|
||||
cerr << endl << endl;
|
||||
}
|
||||
|
||||
if (options.get("h")) {
|
||||
if (options.get(String("h"))) {
|
||||
printHelp();
|
||||
return 0;
|
||||
}
|
||||
String* xmlFilename = (String*)options.get("i");
|
||||
String* xsltFilename = (String*)options.get("s");
|
||||
String* outFilename = (String*)options.get("o");
|
||||
String* xmlFilename = (String*)options.get(String("i"));
|
||||
String* xsltFilename = (String*)options.get(String("s"));
|
||||
String* outFilename = (String*)options.get(String("o"));
|
||||
|
||||
|
||||
//-- open XML file
|
||||
istream* xmlInput = &cin;
|
||||
if (xmlFilename && ! xmlFilename->isEqual("-")) {
|
||||
char* chars = new char[xmlFilename->length()+1];
|
||||
xmlInput = new ifstream(xmlFilename->toCharArray(chars), ios::in);
|
||||
delete chars;
|
||||
char* chars = xmlFilename->toCharArray();
|
||||
xmlInput = new ifstream(chars, ios::in);
|
||||
delete [] chars;
|
||||
}
|
||||
|
||||
//-- handle output stream
|
||||
ostream* resultOutput = &cout;
|
||||
ofstream resultFileStream;
|
||||
if ( outFilename && ! outFilename->isEqual("-")) {
|
||||
char* chars = new char[outFilename->length()+1];
|
||||
resultFileStream.open(outFilename->toCharArray(chars), ios::out);
|
||||
delete chars;
|
||||
char* chars = outFilename->toCharArray();
|
||||
resultFileStream.open(chars, ios::out);
|
||||
delete [] chars;
|
||||
if ( !resultFileStream ) {
|
||||
cerr << "error opening output file: " << *xmlFilename << endl;
|
||||
return -1;
|
||||
|
@ -132,9 +133,9 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
else {
|
||||
//-- open XSLT file
|
||||
char* chars = new char[xsltFilename->length()+1];
|
||||
ifstream xsltInput(xsltFilename->toCharArray(chars), ios::in);
|
||||
delete chars;
|
||||
char* chars = xsltFilename->toCharArray();
|
||||
ifstream xsltInput(chars, ios::in);
|
||||
delete [] chars;
|
||||
xsltProcessor.process(*xmlInput, *xmlFilename, xsltInput, *xsltFilename, *resultOutput);
|
||||
}
|
||||
resultFileStream.close();
|
||||
|
|
|
@ -39,17 +39,17 @@ nsresult txExpandedName::init(const String& aQName,
|
|||
if (!XMLUtils::isValidQName(aQName))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
int idx = aQName.indexOf(':');
|
||||
if (idx >= 0) {
|
||||
PRInt32 idx = aQName.indexOf(':');
|
||||
if (idx != kNotFound) {
|
||||
String localName, prefixStr;
|
||||
aQName.subString(0, idx, prefixStr);
|
||||
aQName.subString(0, (PRUint32)idx, prefixStr);
|
||||
txAtom* prefix = TX_GET_ATOM(prefixStr);
|
||||
PRInt32 namespaceID = aResolver->lookupNamespaceID(prefix);
|
||||
if (namespaceID == kNameSpaceID_Unknown)
|
||||
return NS_ERROR_FAILURE;
|
||||
mNamespaceID = namespaceID;
|
||||
|
||||
aQName.subString(idx+1, localName);
|
||||
aQName.subString((PRUint32)idx + 1, localName);
|
||||
TX_IF_RELEASE_ATOM(mLocalName);
|
||||
mLocalName = TX_GET_ATOM(localName);
|
||||
}
|
||||
|
@ -68,33 +68,36 @@ nsresult txExpandedName::init(const String& aQName,
|
|||
//- Implementation of XMLUtils -/
|
||||
//------------------------------/
|
||||
|
||||
void XMLUtils::getPrefix(const String& src, String& dest) {
|
||||
|
||||
//-- anything preceding ':' is the namespace part of the name
|
||||
int idx = src.indexOf(':');
|
||||
if ( idx > 0 ) {
|
||||
//-- create new String to prevent any chars in dest from being
|
||||
//-- lost
|
||||
String tmp;
|
||||
src.subString(0,idx, tmp);
|
||||
dest.append(tmp);
|
||||
void XMLUtils::getPrefix(const String& src, String& dest)
|
||||
{
|
||||
// Anything preceding ':' is the namespace part of the name
|
||||
PRInt32 idx = src.indexOf(':');
|
||||
if (idx == kNotFound) {
|
||||
return;
|
||||
}
|
||||
else dest.append("");
|
||||
|
||||
// Use a temporary String to prevent any chars in dest
|
||||
// from being lost.
|
||||
NS_ASSERTION(idx > 0, "This QName looks invalid.");
|
||||
String tmp;
|
||||
src.subString(0, (PRUint32)idx, tmp);
|
||||
dest.append(tmp);
|
||||
}
|
||||
|
||||
void XMLUtils::getLocalPart(const String& src, String& dest) {
|
||||
|
||||
//-- anything after ':' is the local part of the name
|
||||
int idx = src.indexOf(':');
|
||||
if ( idx < -1 ) idx = -1;
|
||||
//-- create new String to prevent any chars in dest from being
|
||||
//-- lost
|
||||
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);
|
||||
return;
|
||||
}
|
||||
// Use a temporary String to prevent any chars in dest
|
||||
// from being lost.
|
||||
NS_ASSERTION(idx > 0, "This QName looks invalid.");
|
||||
String tmp;
|
||||
src.subString(idx+1, tmp);
|
||||
src.subString((PRUint32)idx + 1, tmp);
|
||||
dest.append(tmp);
|
||||
|
||||
} //-- getLocalPart
|
||||
}
|
||||
|
||||
MBool XMLUtils::isValidQName(const String& aName)
|
||||
{
|
||||
|
@ -139,74 +142,49 @@ MBool XMLUtils::isValidQName(const String& aName)
|
|||
/**
|
||||
* Returns true if the given string has only whitespace characters
|
||||
**/
|
||||
MBool XMLUtils::isWhitespace(const String& text) {
|
||||
for ( int i = 0; i < text.length(); i++ ) {
|
||||
PRInt32 ch = text.charAt(i);
|
||||
switch ( ch ) {
|
||||
case ' ' :
|
||||
case '\n' :
|
||||
case '\r' :
|
||||
case '\t' :
|
||||
break;
|
||||
default:
|
||||
return MB_FALSE;
|
||||
MBool XMLUtils::isWhitespace(const String& aText)
|
||||
{
|
||||
PRUint32 size = aText.length();
|
||||
PRUint32 i;
|
||||
for (i = 0; i < size; ++i) {
|
||||
if (!isWhitespace(aText.charAt(i))) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
}
|
||||
return MB_TRUE;
|
||||
} //-- isWhitespace
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the value of a XML processing instruction
|
||||
**/
|
||||
void XMLUtils::normalizePIValue(String& piValue) {
|
||||
PRInt32 size = piValue.length();
|
||||
//-- make copy of chars
|
||||
UNICODE_CHAR* chars = new UNICODE_CHAR[size];
|
||||
piValue.toUnicode(chars);
|
||||
//-- clear attValue
|
||||
void XMLUtils::normalizePIValue(String& piValue)
|
||||
{
|
||||
String origValue(piValue);
|
||||
PRUint32 origLength = origValue.length();
|
||||
PRUint32 conversionLoop = 0;
|
||||
UNICODE_CHAR prevCh = 0;
|
||||
piValue.clear();
|
||||
|
||||
PRInt32 cc = 0;
|
||||
UNICODE_CHAR prevCh = 0x0000;
|
||||
while ( cc < size) {
|
||||
UNICODE_CHAR ch = chars[cc++];
|
||||
while (conversionLoop < origLength) {
|
||||
UNICODE_CHAR ch = origValue.charAt(conversionLoop);
|
||||
switch (ch) {
|
||||
case '>':
|
||||
if ( prevCh == '?' ) {
|
||||
{
|
||||
if (prevCh == '?') {
|
||||
piValue.append(' ');
|
||||
}
|
||||
piValue.append(ch);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
piValue.append(ch);
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
piValue.append(ch);
|
||||
prevCh = ch;
|
||||
++conversionLoop;
|
||||
}
|
||||
delete chars;
|
||||
} //-- noramlizePIValue
|
||||
|
||||
/**
|
||||
* Is this a whitespace string to be stripped?
|
||||
* Newlines (#xD), tabs (#x9), spaces (#x20), CRs (#xA) only?
|
||||
* @param data the String to test for whitespace
|
||||
**/
|
||||
MBool XMLUtils::shouldStripTextnode (const String& data){
|
||||
MBool toStrip = MB_TRUE;
|
||||
for (PRInt32 i=0;toStrip && i<data.length();i++){
|
||||
switch(data.charAt(i)) {
|
||||
case 0x0020: // space
|
||||
case 0x0009: // tab
|
||||
case 0x000A: // LF
|
||||
case 0x000D: // CR
|
||||
break;
|
||||
default:
|
||||
toStrip = MB_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return toStrip;
|
||||
} //-- shouldStripTextnode
|
||||
}
|
||||
|
||||
// macros for inclusion of char range headers
|
||||
#define TX_CHAR_RANGE(ch, a, b) if (ch < a) return MB_FALSE; \
|
||||
|
|
|
@ -103,23 +103,26 @@ public:
|
|||
*/
|
||||
static MBool isValidQName(const String& aName);
|
||||
|
||||
/*
|
||||
* Returns true if the given character is whitespace.
|
||||
*/
|
||||
static MBool isWhitespace(const UNICODE_CHAR& aChar)
|
||||
{
|
||||
return (aChar <= ' ' &&
|
||||
(aChar == ' ' || aChar == '\r' ||
|
||||
aChar == '\n'|| aChar == '\t'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given string has only whitespace characters
|
||||
**/
|
||||
static MBool isWhitespace(const String& text);
|
||||
static MBool isWhitespace(const String& aText);
|
||||
|
||||
/**
|
||||
* Normalizes the value of a XML processingInstruction
|
||||
**/
|
||||
static void normalizePIValue(String& attValue);
|
||||
|
||||
/**
|
||||
* Is this a whitespace string to be stripped?
|
||||
* Newlines (#xD), tabs (#x9), spaces (#x20), CRs (#xA) only?
|
||||
* @param data the String to test for whitespace
|
||||
**/
|
||||
static MBool shouldStripTextnode (const String& data);
|
||||
|
||||
/*
|
||||
* Returns true if the given character represents a numeric letter (digit).
|
||||
*/
|
||||
|
|
|
@ -79,7 +79,7 @@ void CharacterData::setData(const String& aData)
|
|||
*
|
||||
* @return the length of the character data
|
||||
*/
|
||||
PRInt32 CharacterData::getLength() const
|
||||
PRUint32 CharacterData::getLength() const
|
||||
{
|
||||
NSI_FROM_TX(CharacterData)
|
||||
PRUint32 length = 0;
|
||||
|
@ -99,7 +99,7 @@ PRInt32 CharacterData::getLength() const
|
|||
*
|
||||
* @return the length of the character data
|
||||
*/
|
||||
String& CharacterData::substringData(PRInt32 aOffset, PRInt32 aCount,
|
||||
String& CharacterData::substringData(PRUint32 aOffset, PRUint32 aCount,
|
||||
String& aDest)
|
||||
{
|
||||
NSI_FROM_TX(CharacterData)
|
||||
|
@ -129,7 +129,7 @@ void CharacterData::appendData(const String& aSource)
|
|||
* @param aOffset the offset at which you want to insert the string
|
||||
* @param aSource the string that you want to insert into the character data
|
||||
*/
|
||||
void CharacterData::insertData(PRInt32 aOffset, const String& aSource)
|
||||
void CharacterData::insertData(PRUint32 aOffset, const String& aSource)
|
||||
{
|
||||
NSI_FROM_TX(CharacterData)
|
||||
|
||||
|
@ -143,7 +143,7 @@ void CharacterData::insertData(PRInt32 aOffset, const String& aSource)
|
|||
* @param aOffset the offset at which you want to delete data
|
||||
* @param aCount the number of chars you want to delete
|
||||
*/
|
||||
void CharacterData::deleteData(PRInt32 aOffset, PRInt32 aCount)
|
||||
void CharacterData::deleteData(PRUint32 aOffset, PRUint32 aCount)
|
||||
{
|
||||
NSI_FROM_TX(CharacterData)
|
||||
|
||||
|
@ -158,7 +158,7 @@ void CharacterData::deleteData(PRInt32 aOffset, PRInt32 aCount)
|
|||
* @param aCount the number of chars you want to replace
|
||||
* @param aSource the data that you want to replace it with
|
||||
*/
|
||||
void CharacterData::replaceData(PRInt32 aOffset, PRInt32 aCount,
|
||||
void CharacterData::replaceData(PRUint32 aOffset, PRUint32 aCount,
|
||||
const String& aSource)
|
||||
{
|
||||
NSI_FROM_TX(CharacterData)
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* Contributor(s): Tom Kneeland
|
||||
* Peter Van der Beken <peter.vanderbeken@pandora.be>
|
||||
*
|
||||
*/
|
||||
|
||||
/* Implementation of the wrapper class to convert the Mozilla nsIDOMText
|
||||
interface into a TransforMIIX Text interface.
|
||||
*/
|
||||
|
||||
#include "mozilladom.h"
|
||||
|
||||
/**
|
||||
* Construct a wrapper with the specified Mozilla object and document owner.
|
||||
*
|
||||
* @param aText the nsIDOMCharacterData you want to wrap
|
||||
* @param aOwner the document that owns this object
|
||||
*/
|
||||
Text::Text(nsIDOMText* aText, Document* aOwner) : CharacterData(aText, aOwner)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
Text::~Text()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMText::SplitText to split the text.
|
||||
*
|
||||
* @param aOffset the offset at which you want to split
|
||||
*
|
||||
* @return the resulting Text object
|
||||
*/
|
||||
Text* Text::splitText(PRInt32 aOffset)
|
||||
{
|
||||
NSI_FROM_TX_NULL_CHECK(Text)
|
||||
nsCOMPtr<nsIDOMText> split;
|
||||
|
||||
if (NS_SUCCEEDED(nsText->SplitText(aOffset, getter_AddRefs(split))))
|
||||
return (Text*)ownerDocument->createWrapper(split);
|
||||
else
|
||||
return NULL;
|
||||
}
|
|
@ -471,13 +471,13 @@ class CharacterData : public Node
|
|||
|
||||
const String& getData();
|
||||
void setData(const String& aSource);
|
||||
PRInt32 getLength() const;
|
||||
PRUint32 getLength() const;
|
||||
|
||||
String& substringData(PRInt32 aOffset, PRInt32 aCount, String& aDest);
|
||||
String& substringData(PRUint32 aOffset, PRUint32 aCount, String& aDest);
|
||||
void appendData(const String& aSource);
|
||||
void insertData(PRInt32 aOffset, const String& aSource);
|
||||
void deleteData(PRInt32 aOffset, PRInt32 aCount);
|
||||
void replaceData(PRInt32 aOffset, PRInt32 aCount, const String& aSource);
|
||||
void insertData(PRUint32 aOffset, const String& aSource);
|
||||
void deleteData(PRUint32 aOffset, PRUint32 aCount);
|
||||
void replaceData(PRUint32 aOffset, PRUint32 aCount, const String& aSource);
|
||||
|
||||
private:
|
||||
String nodeValue;
|
||||
|
@ -492,7 +492,7 @@ class Text : public CharacterData
|
|||
Text(nsIDOMText* aText, Document* aOwner);
|
||||
~Text();
|
||||
|
||||
Text* splitText(PRInt32 aOffset);
|
||||
Text* splitText(PRUint32 aOffset);
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -38,7 +38,7 @@ Attr::Attr(const String& name, Document* owner):
|
|||
specified = MB_FALSE;
|
||||
|
||||
int idx = nodeName.indexOf(':');
|
||||
if (idx == NOT_FOUND) {
|
||||
if (idx == kNotFound) {
|
||||
mLocalName = TX_GET_ATOM(nodeName);
|
||||
if (mLocalName == txXMLAtoms::xmlns)
|
||||
mNamespaceID = kNameSpaceID_XMLNS;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
//Construct a text object with the specified document owner and data
|
||||
//
|
||||
CDATASection::CDATASection(const String& theData, Document* owner) :
|
||||
Text(Node::CDATA_SECTION_NODE, "#cdata-section", theData, owner)
|
||||
Text(Node::CDATA_SECTION_NODE, String("#cdata-section"), theData, owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void CharacterData::setData(const String& source)
|
|||
//
|
||||
//Returns the length of the data object.
|
||||
//
|
||||
PRInt32 CharacterData::getLength() const
|
||||
PRUint32 CharacterData::getLength() const
|
||||
{
|
||||
return nodeValue.length();
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ PRInt32 CharacterData::getLength() const
|
|||
//characters away.
|
||||
// NOTE: An empty string will be returned in the event of an error.
|
||||
//
|
||||
String& CharacterData::substringData(PRInt32 offset, PRInt32 count, String& dest)
|
||||
String& CharacterData::substringData(PRUint32 offset, PRUint32 count, String& dest)
|
||||
{
|
||||
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0))
|
||||
if ((offset < nodeValue.length()) && (count > 0))
|
||||
return nodeValue.subString(offset, offset+count, dest);
|
||||
else
|
||||
{
|
||||
|
@ -84,23 +84,23 @@ void CharacterData::appendData(const String& arg)
|
|||
nodeValue.append(arg);
|
||||
}
|
||||
|
||||
void CharacterData::insertData(PRInt32 offset, const String& arg)
|
||||
void CharacterData::insertData(PRUint32 offset, const String& arg)
|
||||
{
|
||||
if ((offset >= 0) && (offset < nodeValue.length()))
|
||||
if (offset < nodeValue.length())
|
||||
nodeValue.insert(offset, arg);
|
||||
}
|
||||
|
||||
void CharacterData::deleteData(PRInt32 offset, PRInt32 count)
|
||||
void CharacterData::deleteData(PRUint32 offset, PRUint32 count)
|
||||
{
|
||||
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0))
|
||||
if ((offset < nodeValue.length()) && (count > 0))
|
||||
nodeValue.deleteChars(offset, count);
|
||||
}
|
||||
|
||||
void CharacterData::replaceData(PRInt32 offset, PRInt32 count, const String& arg)
|
||||
void CharacterData::replaceData(PRUint32 offset, PRUint32 count, const String& arg)
|
||||
{
|
||||
String tempString;
|
||||
|
||||
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0))
|
||||
if ((offset < nodeValue.length()) && (count > 0))
|
||||
{
|
||||
if (count < arg.length())
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
//Construct a text object with the specified document owner and data
|
||||
//
|
||||
Comment::Comment(const String& theData, Document* owner) :
|
||||
CharacterData(Node::COMMENT_NODE, "#comment", theData, owner)
|
||||
CharacterData(Node::COMMENT_NODE, String("#comment"), theData, owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,9 @@
|
|||
|
||||
#include "dom.h"
|
||||
|
||||
DOMImplementation::DOMImplementation()
|
||||
DOMImplementation::DOMImplementation() : implFeature("XML"),
|
||||
implVersion("1.0")
|
||||
{
|
||||
implFeature = "XML";
|
||||
implVersion = "1.0";
|
||||
}
|
||||
|
||||
DOMImplementation::~DOMImplementation()
|
||||
|
@ -45,7 +44,7 @@ DOMImplementation::~DOMImplementation()
|
|||
//functionality of this DOM implementation/version.
|
||||
//
|
||||
MBool DOMImplementation::hasFeature(String feature,
|
||||
const String& version) const
|
||||
const String& version) const
|
||||
{
|
||||
feature.toUpperCase();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
//node constructor is called to identify the node type.
|
||||
//
|
||||
Document::Document(DocumentType* theDoctype) :
|
||||
NodeDefinition(Node::DOCUMENT_NODE, "#document", NULL_STRING, NULL)
|
||||
NodeDefinition(Node::DOCUMENT_NODE, String("#document"), NULL_STRING, NULL)
|
||||
{
|
||||
documentElement = NULL;
|
||||
doctype = theDoctype;
|
||||
|
@ -195,7 +195,7 @@ Node* Document::removeChild(Node* oldChild)
|
|||
//
|
||||
DocumentFragment* Document::createDocumentFragment()
|
||||
{
|
||||
return new DocumentFragment("#document-fragment", NULL_STRING, this);
|
||||
return new DocumentFragment(String("#document-fragment"), NULL_STRING, this);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -41,7 +41,7 @@ Element::Element(const String& tagName, Document* owner) :
|
|||
mNamespaceID = kNameSpaceID_Unknown;
|
||||
|
||||
int idx = nodeName.indexOf(':');
|
||||
if (idx == NOT_FOUND) {
|
||||
if (idx == kNotFound) {
|
||||
mLocalName = TX_GET_ATOM(nodeName);
|
||||
}
|
||||
else {
|
||||
|
@ -93,7 +93,7 @@ PRInt32 Element::getNamespaceID()
|
|||
if (mNamespaceID>=0)
|
||||
return mNamespaceID;
|
||||
int idx = nodeName.indexOf(':');
|
||||
if (idx == NOT_FOUND) {
|
||||
if (idx == kNotFound) {
|
||||
Node* node = this;
|
||||
while (node && node->getNodeType() == Node::ELEMENT_NODE) {
|
||||
String nsURI;
|
||||
|
|
|
@ -399,7 +399,7 @@ PRInt32 NodeDefinition::lookupNamespaceID(txAtom* aPrefix)
|
|||
else {
|
||||
// No prefix, look up the default namespace by searching for xmlns
|
||||
// attributes. Remove the trailing :, set length to 5 (xmlns).
|
||||
name.setLength(5);
|
||||
name.truncate(5);
|
||||
}
|
||||
Attr* xmlns;
|
||||
while (node && node->getNodeType() == Node::ELEMENT_NODE) {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
//Construct a text object with the specified document owner and data
|
||||
//
|
||||
Text::Text(const String& theData, Document* owner) :
|
||||
CharacterData(Node::TEXT_NODE, "#text", theData, owner)
|
||||
CharacterData(Node::TEXT_NODE, String("#text"), theData, owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -52,12 +52,12 @@ Text::Text(NodeType type, const String& name, const String& value,
|
|||
//Split the text node at Offset into two siblings. Return a pointer to the new
|
||||
//sibling.
|
||||
//
|
||||
Text* Text::splitText(PRInt32 offset)
|
||||
Text* Text::splitText(PRUint32 offset)
|
||||
{
|
||||
Text* newTextSibling = NULL;
|
||||
String newData;
|
||||
|
||||
if ((offset >= 0) && (offset < nodeValue.length()))
|
||||
if (offset < nodeValue.length())
|
||||
{
|
||||
newTextSibling = getOwnerDocument()->createTextNode(nodeValue.subString(offset, newData));
|
||||
getParentNode()->insertBefore(newTextSibling, getNextSibling());
|
||||
|
|
|
@ -510,13 +510,13 @@ class CharacterData : public NodeDefinition
|
|||
public:
|
||||
const String& getData() const;
|
||||
void setData(const String& source);
|
||||
PRInt32 getLength() const;
|
||||
PRUint32 getLength() const;
|
||||
|
||||
String& substringData(PRInt32 offset, PRInt32 count, String& dest);
|
||||
String& substringData(PRUint32 offset, PRUint32 count, String& dest);
|
||||
void appendData(const String& arg);
|
||||
void insertData(PRInt32 offset, const String& arg);
|
||||
void deleteData(PRInt32 offset, PRInt32 count);
|
||||
void replaceData(PRInt32 offset, PRInt32 count, const String& arg);
|
||||
void insertData(PRUint32 offset, const String& arg);
|
||||
void deleteData(PRUint32 offset, PRUint32 count);
|
||||
void replaceData(PRUint32 offset, PRUint32 count, const String& arg);
|
||||
|
||||
protected:
|
||||
CharacterData(NodeType type, const String& name,
|
||||
|
@ -532,7 +532,7 @@ class Text : public CharacterData
|
|||
public:
|
||||
Text(const String& theData, Document* owner);
|
||||
|
||||
Text* splitText(PRInt32 offset);
|
||||
Text* splitText(PRUint32 offset);
|
||||
|
||||
//Override "child manipulation" function since Text Nodes can not have
|
||||
//any children.
|
||||
|
|
|
@ -168,8 +168,6 @@ void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
|
|||
{
|
||||
ParserState* ps = (ParserState*)userData;
|
||||
Element* newElement;
|
||||
XML_Char* attName;
|
||||
XML_Char* attValue;
|
||||
XML_Char** theAtts = (XML_Char**)atts;
|
||||
|
||||
String nodeName((UNICODE_CHAR *)name);
|
||||
|
@ -177,9 +175,9 @@ void startElement(void *userData, const XML_Char *name, const XML_Char **atts)
|
|||
|
||||
while (*theAtts)
|
||||
{
|
||||
attName = *theAtts++;
|
||||
attValue = *theAtts++;
|
||||
newElement->setAttribute((UNICODE_CHAR *)attName, (UNICODE_CHAR *)attValue);
|
||||
String attName((UNICODE_CHAR *)*theAtts++);
|
||||
String attValue((UNICODE_CHAR *)*theAtts++);
|
||||
newElement->setAttribute(attName, attValue);
|
||||
}
|
||||
|
||||
ps->currentNode->appendChild(newElement);
|
||||
|
@ -197,8 +195,7 @@ void endElement(void *userData, const XML_Char* name)
|
|||
void charData(void* userData, const XML_Char* s, int len)
|
||||
{
|
||||
ParserState* ps = (ParserState*)userData;
|
||||
String data;
|
||||
data.append((UNICODE_CHAR*)s, len);
|
||||
String data((UNICODE_CHAR*)s, len);
|
||||
Node* prevSib = ps->currentNode->getLastChild();
|
||||
if (prevSib && prevSib->getNodeType()==Node::TEXT_NODE){
|
||||
((CharacterData*)prevSib)->appendData(data);
|
||||
|
|
|
@ -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("comment");
|
||||
const String ExprLexer::NODE("node");
|
||||
const String ExprLexer::PROC_INST("processing-instruction");
|
||||
const String ExprLexer::TEXT("text");
|
||||
|
||||
//-- boolean
|
||||
const String ExprLexer::AND = "and";
|
||||
const String ExprLexer::OR = "or";
|
||||
const String ExprLexer::AND("and");
|
||||
const String ExprLexer::OR("or");
|
||||
|
||||
//-- multiplicative operators
|
||||
const String ExprLexer::MODULUS = "mod";
|
||||
const String ExprLexer::DIVIDE = "div";
|
||||
const String ExprLexer::MODULUS("mod");
|
||||
const String ExprLexer::DIVIDE("div");
|
||||
|
||||
/**
|
||||
* The set of Lexer error messages
|
||||
**/
|
||||
const String ExprLexer::error_message[] =
|
||||
{
|
||||
"VariableReference expected",
|
||||
"Operator expected",
|
||||
"Literal is not closed",
|
||||
": not expected",
|
||||
"! not expected, use != or not()",
|
||||
"found a unkown character"
|
||||
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")
|
||||
};
|
||||
|
||||
//---------------/
|
||||
|
@ -238,8 +238,8 @@ void ExprLexer::parse(const String& pattern)
|
|||
return;
|
||||
|
||||
String tokenBuffer;
|
||||
PRInt32 iter = 0, start;
|
||||
PRInt32 size = pattern.length();
|
||||
PRUint32 iter = 0, start;
|
||||
PRUint32 size = pattern.length();
|
||||
short defType;
|
||||
UNICODE_CHAR ch;
|
||||
|
||||
|
@ -278,8 +278,8 @@ void ExprLexer::parse(const String& pattern)
|
|||
start = iter;
|
||||
while (++iter < size &&
|
||||
XMLUtils::isNCNameChar(pattern.charAt(iter))) /* just go */ ;
|
||||
PRInt32 end = iter;
|
||||
if (pattern.charAt(iter)==COLON) {
|
||||
PRUint32 end = iter;
|
||||
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)))
|
||||
|
@ -319,7 +319,7 @@ void ExprLexer::parse(const String& pattern)
|
|||
start = iter;
|
||||
while (++iter < size &&
|
||||
isXPathDigit(pattern.charAt(iter))) /* just go */;
|
||||
if (pattern.charAt(iter)=='.')
|
||||
if (iter < size && pattern.charAt(iter) == '.')
|
||||
while (++iter < size &&
|
||||
isXPathDigit(pattern.charAt(iter))) /* just go */;
|
||||
addToken(new Token(pattern.subString(start,iter,subStr),Token::NUMBER));
|
||||
|
@ -336,8 +336,8 @@ void ExprLexer::parse(const String& pattern)
|
|||
case S_QUOTE :
|
||||
case D_QUOTE :
|
||||
start=iter;
|
||||
iter = pattern.indexOf(ch,start+1);
|
||||
if (iter==NOT_FOUND) {
|
||||
iter = pattern.indexOf(ch, (PRInt32)start + 1);
|
||||
if (iter == kNotFound) {
|
||||
// XXX Error reporting "unclosed literal"
|
||||
errorPos = start;
|
||||
errorCode = ERROR_UNCLOSED_LITERAL;
|
||||
|
|
|
@ -182,7 +182,7 @@ public:
|
|||
ERROR_UNKNOWN_CHAR
|
||||
};
|
||||
static const String error_message[];
|
||||
PRInt32 errorPos;
|
||||
PRUint32 errorPos;
|
||||
short errorCode;
|
||||
|
||||
/*
|
||||
|
|
|
@ -56,8 +56,8 @@ AttributeValueTemplate* ExprParser::createAttributeValueTemplate
|
|||
if (attValue.isEmpty())
|
||||
return avt; //XXX should return 0, but that causes crash in lre12
|
||||
|
||||
PRInt32 size = attValue.length();
|
||||
int cc = 0;
|
||||
PRUint32 size = attValue.length();
|
||||
PRUint32 cc = 0;
|
||||
UNICODE_CHAR nextCh;
|
||||
UNICODE_CHAR ch;
|
||||
String buffer;
|
||||
|
@ -956,14 +956,14 @@ nsresult ExprParser::resolveQName(const String& aQName,
|
|||
{
|
||||
aNamespace = kNameSpaceID_None;
|
||||
String prefix, lName;
|
||||
int idx = aQName.indexOf(':');
|
||||
PRInt32 idx = aQName.indexOf(':');
|
||||
if (idx > 0) {
|
||||
aQName.subString(0, idx, prefix);
|
||||
aQName.subString(0, (PRUint32)idx, prefix);
|
||||
aPrefix = TX_GET_ATOM(prefix);
|
||||
if (!aPrefix) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
aQName.subString(idx + 1, lName);
|
||||
aQName.subString((PRUint32)idx + 1, lName);
|
||||
aLocalName = TX_GET_ATOM(lName);
|
||||
if (!aLocalName) {
|
||||
TX_RELEASE_ATOM(aPrefix);
|
||||
|
|
|
@ -30,19 +30,19 @@
|
|||
* This class represents a FunctionCall as defined by the XSL Working Draft
|
||||
**/
|
||||
|
||||
const String FunctionCall::INVALID_PARAM_COUNT =
|
||||
"invalid number of parameters for function: ";
|
||||
const String FunctionCall::INVALID_PARAM_COUNT(
|
||||
"invalid number of parameters for function: ");
|
||||
|
||||
const String FunctionCall::INVALID_PARAM_VALUE =
|
||||
"invalid parameter value for function: ";
|
||||
const String FunctionCall::INVALID_PARAM_VALUE(
|
||||
"invalid parameter value for function: ");
|
||||
|
||||
//- Constructors -/
|
||||
|
||||
/**
|
||||
* Creates a new FunctionCall
|
||||
**/
|
||||
FunctionCall::FunctionCall() {
|
||||
this->name = "void";
|
||||
FunctionCall::FunctionCall() : name("void")
|
||||
{
|
||||
} //-- FunctionCall
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,13 +72,6 @@ static const String NUMBER_FN;
|
|||
static const String ROUND_FN;
|
||||
static const String CEILING_FN;
|
||||
static const String FLOOR_FN;
|
||||
// OG-
|
||||
|
||||
|
||||
//-- internal XSL processor functions
|
||||
static const String ERROR_FN;
|
||||
|
||||
|
||||
}; //-- XPathNames
|
||||
|
||||
|
||||
|
|
|
@ -40,10 +40,10 @@
|
|||
//- PathExpr -/
|
||||
//------------/
|
||||
|
||||
const String PathExpr::RTF_INVALID_OP =
|
||||
"Result tree fragments don't allow location steps";
|
||||
const String PathExpr::NODESET_EXPECTED =
|
||||
"Filter expression must evaluate to a NodeSet";
|
||||
const String PathExpr::RTF_INVALID_OP(
|
||||
"Result tree fragments don't allow location steps");
|
||||
const String PathExpr::NODESET_EXPECTED(
|
||||
"Filter expression must evaluate to a NodeSet");
|
||||
|
||||
/**
|
||||
* Creates a new PathExpr
|
||||
|
@ -177,7 +177,7 @@ void PathExpr::evalDescendants (Expr* aStep, Node* aNode,
|
|||
if (!(filterWS &&
|
||||
(child->getNodeType() == Node::TEXT_NODE ||
|
||||
child->getNodeType() == Node::CDATA_SECTION_NODE) &&
|
||||
XMLUtils::shouldStripTextnode(child->getNodeValue())))
|
||||
XMLUtils::isWhitespace(child->getNodeValue())))
|
||||
evalDescendants(aStep, child, aContext, resNodes);
|
||||
child = child->getNextSibling();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ ExprResult* StringExpr::evaluate(txIEvalContext* aContext)
|
|||
**/
|
||||
void StringExpr::toString(String& str) {
|
||||
UNICODE_CHAR ch = '\'';
|
||||
if (value.indexOf(ch) != NOT_FOUND)
|
||||
if (value.indexOf(ch) != kNotFound)
|
||||
ch = '\"';
|
||||
str.append(ch);
|
||||
str.append(value);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "FunctionLib.h"
|
||||
#include "XMLDOMUtils.h"
|
||||
#include "XMLUtils.h"
|
||||
#include "txIXPathContext.h"
|
||||
#include <math.h>
|
||||
|
||||
|
@ -118,11 +119,10 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
MBool first = MB_TRUE;
|
||||
String normed(resultStr.length());
|
||||
UNICODE_CHAR c;
|
||||
PRInt32 src;
|
||||
PRUint32 src;
|
||||
for (src = 0; src < resultStr.length(); src++) {
|
||||
c = resultStr.charAt(src);
|
||||
if (c == ' ' || c == '\n' ||
|
||||
c == '\t' || c == '\r') {
|
||||
if (XMLUtils::isWhitespace(c)) {
|
||||
addSpace = MB_TRUE;
|
||||
}
|
||||
else {
|
||||
|
@ -198,7 +198,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
return new StringResult();
|
||||
|
||||
String resultStr;
|
||||
src.subString((PRInt32)start, (PRInt32)end, resultStr);
|
||||
src.subString((PRUint32)start, (PRUint32)end, resultStr);
|
||||
return new StringResult(resultStr);
|
||||
}
|
||||
case SUBSTRING_AFTER:
|
||||
|
@ -210,8 +210,8 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
evaluateToString((Expr*)iter.next(), aContext, arg1);
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg2);
|
||||
PRInt32 idx = arg1.indexOf(arg2);
|
||||
if (idx >= 0) {
|
||||
PRInt32 len = arg2.length();
|
||||
if (idx != kNotFound) {
|
||||
PRUint32 len = arg2.length();
|
||||
arg1.subString(idx + len, arg2);
|
||||
return new StringResult(arg2);
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
evaluateToString((Expr*)iter.next(), aContext, arg1);
|
||||
evaluateToString((Expr*)iter.next(), aContext, arg2);
|
||||
PRInt32 idx = arg1.indexOf(arg2);
|
||||
if (idx >= 0) {
|
||||
if (idx != kNotFound) {
|
||||
arg2.clear();
|
||||
arg1.subString(0, idx, arg2);
|
||||
return new StringResult(arg2);
|
||||
|
@ -246,12 +246,12 @@ ExprResult* StringFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
String oldChars, newChars, dest;
|
||||
evaluateToString((Expr*)iter.next(), aContext, oldChars);
|
||||
evaluateToString((Expr*)iter.next(), aContext, newChars);
|
||||
PRInt32 i;
|
||||
PRUint32 i;
|
||||
for (i = 0; i < src.length(); i++) {
|
||||
PRInt32 idx = oldChars.indexOf(src.charAt(i));
|
||||
if (idx >= 0) {
|
||||
if (idx != kNotFound) {
|
||||
if (idx < newChars.length())
|
||||
dest.append(newChars.charAt(idx));
|
||||
dest.append(newChars.charAt((PRUint32)idx));
|
||||
}
|
||||
else {
|
||||
dest.append(src.charAt(i));
|
||||
|
|
|
@ -51,7 +51,7 @@ StringResult::StringResult(const String& str) {
|
|||
**/
|
||||
StringResult::StringResult(const char* str) {
|
||||
//-- copy str
|
||||
this->value = str;
|
||||
this->value.append(str);
|
||||
} //-- StringResult
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,69 +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.
|
||||
*
|
||||
* Marina Mechtcheriakova, mmarina@mindspring.com
|
||||
* -- added LANG_FN
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* XPath names
|
||||
**/
|
||||
|
||||
#include "FunctionLib.h"
|
||||
|
||||
//-- Function Names
|
||||
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";
|
||||
// OG+
|
||||
const String XPathNames::NUMBER_FN = "number";
|
||||
const String XPathNames::ROUND_FN = "round";
|
||||
const String XPathNames::CEILING_FN = "ceiling";
|
||||
const String XPathNames::FLOOR_FN = "floor";
|
||||
// OG-
|
||||
//Marina M. boolean function lang
|
||||
const String XPathNames::LANG_FN = "lang";
|
||||
|
||||
//-- internal XSL processor functions
|
||||
const String XPathNames::ERROR_FN = "error";
|
||||
|
|
@ -70,7 +70,7 @@ nsXPathEvaluator::CreateExpression(const nsAString & aExpression,
|
|||
nsIDOMXPathNSResolver *aResolver,
|
||||
nsIDOMXPathExpression **aResult)
|
||||
{
|
||||
String expressionString(PromiseFlatString(aExpression).get());
|
||||
String expressionString(aExpression);
|
||||
ParseContextImpl pContext(aResolver);
|
||||
Expr* expression = ExprParser::createExpr(expressionString, &pContext);
|
||||
if (!expression)
|
||||
|
|
|
@ -37,107 +37,107 @@
|
|||
#include "Names.h"
|
||||
|
||||
//-- Global Strings
|
||||
const String HTML = "html";
|
||||
const String HTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
const String STYLESHEET_PI = "xml-stylesheet";
|
||||
const String STYLESHEET_PI_OLD = "xml:stylesheet";
|
||||
const String XML_SPACE = "xml:space";
|
||||
const String XSL_MIME_TYPE = "text/xsl";
|
||||
const String XSLT_NS = "http://www.w3.org/1999/XSL/Transform";
|
||||
const String HTML("html");
|
||||
const String HTML_NS("http://www.w3.org/1999/xhtml");
|
||||
const String STYLESHEET_PI("xml-stylesheet");
|
||||
const String STYLESHEET_PI_OLD("xml:stylesheet");
|
||||
const String XML_SPACE("xml:space");
|
||||
const String XSL_MIME_TYPE("text/xsl");
|
||||
const String XSLT_NS("http://www.w3.org/1999/XSL/Transform");
|
||||
|
||||
//-- Elements
|
||||
const String APPLY_IMPORTS = "apply-imports";
|
||||
const String APPLY_TEMPLATES = "apply-templates";
|
||||
const String ATTRIBUTE = "attribute";
|
||||
const String ATTRIBUTE_SET = "attribute-set";
|
||||
const String CALL_TEMPLATE = "call-template";
|
||||
const String CHOOSE = "choose";
|
||||
const String COMMENT = "comment";
|
||||
const String COPY = "copy";
|
||||
const String COPY_OF = "copy-of";
|
||||
const String DECIMAL_FORMAT = "decimal-format";
|
||||
const String ELEMENT = "element";
|
||||
const String FOR_EACH = "for-each";
|
||||
const String IF = "if";
|
||||
const String IMPORT = "import";
|
||||
const String INCLUDE = "include";
|
||||
const String KEY = "key";
|
||||
const String MESSAGE = "message";
|
||||
const String NUMBER = "number";
|
||||
const String OTHERWISE = "otherwise";
|
||||
const String OUTPUT = "output";
|
||||
const String PARAM = "param";
|
||||
const String PROC_INST = "processing-instruction";
|
||||
const String PRESERVE_SPACE = "preserve-space";
|
||||
const String SORT = "sort";
|
||||
const String STRIP_SPACE = "strip-space";
|
||||
const String TEMPLATE = "template";
|
||||
const String TEXT = "text";
|
||||
const String VALUE_OF = "value-of";
|
||||
const String VARIABLE = "variable";
|
||||
const String WHEN = "when";
|
||||
const String WITH_PARAM = "with-param";
|
||||
const String APPLY_IMPORTS("apply-imports");
|
||||
const String APPLY_TEMPLATES("apply-templates");
|
||||
const String ATTRIBUTE("attribute");
|
||||
const String ATTRIBUTE_SET("attribute-set");
|
||||
const String CALL_TEMPLATE("call-template");
|
||||
const String CHOOSE("choose");
|
||||
const String COMMENT("comment");
|
||||
const String COPY("copy");
|
||||
const String COPY_OF("copy-of");
|
||||
const String DECIMAL_FORMAT("decimal-format");
|
||||
const String ELEMENT("element");
|
||||
const String FOR_EACH("for-each");
|
||||
const String IF("if");
|
||||
const String IMPORT("import");
|
||||
const String INCLUDE("include");
|
||||
const String KEY("key");
|
||||
const String MESSAGE("message");
|
||||
const String NUMBER("number");
|
||||
const String OTHERWISE("otherwise");
|
||||
const String OUTPUT("output");
|
||||
const String PARAM("param");
|
||||
const String PROC_INST("processing-instruction");
|
||||
const String PRESERVE_SPACE("preserve-space");
|
||||
const String SORT("sort");
|
||||
const String STRIP_SPACE("strip-space");
|
||||
const String TEMPLATE("template");
|
||||
const String TEXT("text");
|
||||
const String VALUE_OF("value-of");
|
||||
const String VARIABLE("variable");
|
||||
const String WHEN("when");
|
||||
const String WITH_PARAM("with-param");
|
||||
|
||||
//-- Attributes
|
||||
const String ELEMENTS_ATTR = "elements";
|
||||
const String HREF_ATTR = "href";
|
||||
const String MATCH_ATTR = "match";
|
||||
const String MODE_ATTR = "mode";
|
||||
const String NAME_ATTR = "name";
|
||||
const String SELECT_ATTR = "select";
|
||||
const String TEST_ATTR = "test";
|
||||
const String USE_ATTR = "use";
|
||||
const String ELEMENTS_ATTR("elements");
|
||||
const String HREF_ATTR("href");
|
||||
const String MATCH_ATTR("match");
|
||||
const String MODE_ATTR("mode");
|
||||
const String NAME_ATTR("name");
|
||||
const String SELECT_ATTR("select");
|
||||
const String TEST_ATTR("test");
|
||||
const String USE_ATTR("use");
|
||||
|
||||
//-- Attribute Values
|
||||
const String ANY_VALUE = "any";
|
||||
const String ASCENDING_VALUE = "ascending";
|
||||
const String DESCENDING_VALUE = "descending";
|
||||
const String LOWER_FIRST_VALUE = "lower-first";
|
||||
const String MULTIPLE_VALUE = "multiple";
|
||||
const String NO_VALUE = "no";
|
||||
const String NUMBER_VALUE = "number";
|
||||
const String PRESERVE_VALUE = "preserve";
|
||||
const String SINGLE_VALUE = "single";
|
||||
const String STRIP_VALUE = "strip";
|
||||
const String TEXT_VALUE = "text";
|
||||
const String UPPER_FIRST_VALUE = "upper-first";
|
||||
const String YES_VALUE = "yes";
|
||||
const String ANY_VALUE("any");
|
||||
const String ASCENDING_VALUE("ascending");
|
||||
const String DESCENDING_VALUE("descending");
|
||||
const String LOWER_FIRST_VALUE("lower-first");
|
||||
const String MULTIPLE_VALUE("multiple");
|
||||
const String NO_VALUE("no");
|
||||
const String NUMBER_VALUE("number");
|
||||
const String PRESERVE_VALUE("preserve");
|
||||
const String SINGLE_VALUE("single");
|
||||
const String STRIP_VALUE("strip");
|
||||
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";
|
||||
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");
|
||||
|
||||
//-- NodeTest Operators
|
||||
const String ATTRIBUTE_FNAME = "@";
|
||||
const String COMMENT_FNAME = "comment";
|
||||
const String PI_FNAME = "processing-instruction";
|
||||
const String TEXT_FNAME = "text";
|
||||
const String NODE_FNAME = "node";
|
||||
const String IDENTITY_OP = ".";
|
||||
const String PARENT_OP = "..";
|
||||
const String ATTRIBUTE_FNAME("@");
|
||||
const String COMMENT_FNAME("comment");
|
||||
const String PI_FNAME("processing-instruction");
|
||||
const String TEXT_FNAME("text");
|
||||
const String NODE_FNAME("node");
|
||||
const String IDENTITY_OP(".");
|
||||
const String PARENT_OP("..");
|
||||
|
||||
//-- XSLT additional functions
|
||||
const String DOCUMENT_FN = "document";
|
||||
const String KEY_FN = "key";
|
||||
const String FORMAT_NUMBER_FN = "format-number";
|
||||
const String CURRENT_FN = "current";
|
||||
const String UNPARSED_ENTITY_URI_FN = "unparsed-entity-uri";
|
||||
const String GENERATE_ID_FN = "generate-id";
|
||||
const String SYSTEM_PROPERTY_FN = "system-property";
|
||||
const String ELEMENT_AVAILABLE_FN = "element-available";
|
||||
const String FUNCTION_AVAILABLE_FN = "function-available";
|
||||
const String DOCUMENT_FN("document");
|
||||
const String KEY_FN("key");
|
||||
const String FORMAT_NUMBER_FN("format-number");
|
||||
const String CURRENT_FN("current");
|
||||
const String UNPARSED_ENTITY_URI_FN("unparsed-entity-uri");
|
||||
const String GENERATE_ID_FN("generate-id");
|
||||
const String SYSTEM_PROPERTY_FN("system-property");
|
||||
const String ELEMENT_AVAILABLE_FN("element-available");
|
||||
const String FUNCTION_AVAILABLE_FN("function-available");
|
||||
|
||||
//-- MISC
|
||||
const String WILD_CARD = "*";
|
||||
const String WILD_CARD("*");
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ ProcessorState::ProcessorState(Document* aSourceDocument,
|
|||
|
||||
// add predefined default decimal format
|
||||
defaultDecimalFormatSet = MB_FALSE;
|
||||
decimalFormats.put("", new txDecimalFormat);
|
||||
decimalFormats.put(String(), new txDecimalFormat);
|
||||
decimalFormats.setObjectDeletion(MB_TRUE);
|
||||
}
|
||||
|
||||
|
@ -461,19 +461,24 @@ Node* ProcessorState::findTemplate(Node* aNode,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
#ifdef PR_LOGGING
|
||||
char *nodeBuf = 0, *modeBuf = 0;
|
||||
if (matchTemplate) {
|
||||
char *matchBuf = 0, *uriBuf = 0;
|
||||
PR_LOG(txLog::xslt, PR_LOG_DEBUG,
|
||||
("MatchTemplate, Pattern %s, Mode %s, Stylesheet %s, " \
|
||||
"Node %s\n",
|
||||
(matchBuf = ((Element*)matchTemplate)->getAttribute("match").toCharArray()),
|
||||
(matchBuf = ((Element*)matchTemplate)->getAttribute(String("match")).toCharArray()),
|
||||
(modeBuf = aMode.toCharArray()),
|
||||
(uriBuf = matchTemplate->getBaseURI().toCharArray()),
|
||||
(nodeBuf = aNode->getNodeName().toCharArray())));
|
||||
delete matchBuf;
|
||||
delete uriBuf;
|
||||
#ifdef TX_EXE
|
||||
delete [] matchBuf;
|
||||
delete [] uriBuf;
|
||||
#else
|
||||
nsMemory::Free(matchBuf);
|
||||
nsMemory::Free(uriBuf);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
PR_LOG(txLog::xslt, PR_LOG_DEBUG,
|
||||
|
@ -481,9 +486,14 @@ Node* ProcessorState::findTemplate(Node* aNode,
|
|||
(nodeBuf = aNode->getNodeName().toCharArray()),
|
||||
(modeBuf = aMode.toCharArray())));
|
||||
}
|
||||
delete nodeBuf;
|
||||
delete modeBuf;
|
||||
#endif
|
||||
#ifdef TX_EXE
|
||||
delete [] nodeBuf;
|
||||
delete [] modeBuf;
|
||||
#else
|
||||
nsMemory::Free(nodeBuf);
|
||||
nsMemory::Free(modeBuf);
|
||||
#endif
|
||||
#endif
|
||||
return matchTemplate;
|
||||
}
|
||||
|
||||
|
@ -557,7 +567,7 @@ Expr* ProcessorState::getExpr(Element* aElem, ExprAttr aAttr)
|
|||
expr = ExprParser::createExpr(attr, &pContext);
|
||||
|
||||
if (!expr) {
|
||||
String err = "Error in parsing XPath expression: ";
|
||||
String err("Error in parsing XPath expression: ");
|
||||
err.append(attr);
|
||||
receiveError(err, NS_ERROR_XPATH_PARSE_FAILED);
|
||||
}
|
||||
|
@ -596,7 +606,7 @@ txPattern* ProcessorState::getPattern(Element* aElem, PatternAttr aAttr)
|
|||
pattern = txPatternParser::createPattern(attr, &pContext, this);
|
||||
|
||||
if (!pattern) {
|
||||
String err = "Error in parsing pattern: ";
|
||||
String err("Error in parsing pattern: ");
|
||||
err.append(attr);
|
||||
receiveError(err, NS_ERROR_XPATH_PARSE_FAILED);
|
||||
}
|
||||
|
@ -929,7 +939,6 @@ MBool ProcessorState::isStripSpaceAllowed(Node* node)
|
|||
ImportFrame* frame;
|
||||
txListIterator frameIter(&mImportFrames);
|
||||
|
||||
String name = node->getNodeName();
|
||||
while ((frame = (ImportFrame*)frameIter.next())) {
|
||||
txListIterator iter(&frame->mWhiteNameTests);
|
||||
while (iter.hasNext()) {
|
||||
|
@ -939,7 +948,7 @@ MBool ProcessorState::isStripSpaceAllowed(Node* node)
|
|||
}
|
||||
}
|
||||
if (mOutputFormat.mMethod == eHTMLOutput) {
|
||||
String ucName = name;
|
||||
String ucName = node->getNodeName();
|
||||
ucName.toUpperCase();
|
||||
if (ucName.isEqual("SCRIPT"))
|
||||
return MB_FALSE;
|
||||
|
@ -949,7 +958,7 @@ MBool ProcessorState::isStripSpaceAllowed(Node* node)
|
|||
case Node::TEXT_NODE:
|
||||
case Node::CDATA_SECTION_NODE:
|
||||
{
|
||||
if (!XMLUtils::shouldStripTextnode(node->getNodeValue()))
|
||||
if (!XMLUtils::isWhitespace(node->getNodeValue()))
|
||||
return MB_FALSE;
|
||||
return isStripSpaceAllowed(node->getParentNode());
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ private:
|
|||
**/
|
||||
class txNameTestItem {
|
||||
public:
|
||||
txNameTestItem(txAtom* aPrefix, txAtom* aLocalName, PRUint32 aNSID,
|
||||
txNameTestItem(txAtom* aPrefix, txAtom* aLocalName, PRInt32 aNSID,
|
||||
MBool stripSpace)
|
||||
: mNameTest(aPrefix, aLocalName, aNSID, Node::ELEMENT_NODE),
|
||||
mStrips(stripSpace)
|
||||
|
|
|
@ -86,8 +86,8 @@
|
|||
* A warning message used by all templates that do not allow non character
|
||||
* data to be generated
|
||||
**/
|
||||
const String XSLTProcessor::NON_TEXT_TEMPLATE_WARNING =
|
||||
"templates for the following element are not allowed to generate non character data: ";
|
||||
const String XSLTProcessor::NON_TEXT_TEMPLATE_WARNING(
|
||||
"templates for the following element are not allowed to generate non character data: ");
|
||||
|
||||
/*
|
||||
* Implement static variables for atomservice and dom.
|
||||
|
@ -239,11 +239,11 @@ void XSLTProcessor::getHrefFromStylesheetPI(Document& xmlDocument, String& href)
|
|||
**/
|
||||
void XSLTProcessor::parseStylesheetPI(String& data, String& type, String& href) {
|
||||
|
||||
PRInt32 size = data.length();
|
||||
PRUint32 size = data.length();
|
||||
NamedMap bufferMap;
|
||||
bufferMap.put("type", &type);
|
||||
bufferMap.put("href", &href);
|
||||
int ccount = 0;
|
||||
bufferMap.put(String("type"), &type);
|
||||
bufferMap.put(String("href"), &href);
|
||||
PRUint32 ccount = 0;
|
||||
MBool inLiteral = MB_FALSE;
|
||||
UNICODE_CHAR matchQuote = '"';
|
||||
String sink;
|
||||
|
@ -1039,7 +1039,7 @@ void XSLTProcessor::processAction(Node* aNode,
|
|||
nodeType == Node::CDATA_SECTION_NODE) {
|
||||
const String& textValue = aXSLTAction->getNodeValue();
|
||||
if (!aPs->isXSLStripSpaceAllowed(aXSLTAction) ||
|
||||
!XMLUtils::shouldStripTextnode(textValue)) {
|
||||
!XMLUtils::isWhitespace(textValue)) {
|
||||
NS_ASSERTION(mResultHandler, "mResultHandler must not be NULL!");
|
||||
mResultHandler->characters(textValue);
|
||||
}
|
||||
|
@ -1323,8 +1323,8 @@ void XSLTProcessor::processAction(Node* aNode,
|
|||
String value;
|
||||
processChildrenAsValue(aNode, actionElement, aPs, MB_TRUE, value);
|
||||
PRInt32 pos = 0;
|
||||
PRInt32 length = value.length();
|
||||
while ((pos = value.indexOf('-', pos)) != NOT_FOUND) {
|
||||
PRUint32 length = value.length();
|
||||
while ((pos = value.indexOf('-', pos)) != kNotFound) {
|
||||
++pos;
|
||||
if ((pos == length) || (value.charAt(pos) == '-'))
|
||||
value.insert(pos++, ' ');
|
||||
|
@ -2258,7 +2258,7 @@ XSLTProcessor::startElement(ProcessorState* aPs, const String& aName, const PRIn
|
|||
if (format->mMethod == eMethodNotSet) {
|
||||
// XXX Should check for whitespace-only sibling text nodes
|
||||
if ((aNsID == kNameSpaceID_None) &&
|
||||
aName.isEqualIgnoreCase("html")) {
|
||||
aName.isEqualIgnoreCase(String("html"))) {
|
||||
// Switch to html output mode according to the XSLT spec.
|
||||
format->mMethod = eHTMLOutput;
|
||||
#ifndef TX_EXE
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include "Names.h"
|
||||
#include "txIXPathContext.h"
|
||||
|
||||
const String XSL_VERSION_PROPERTY = "version";
|
||||
const String XSL_VENDOR_PROPERTY = "vendor";
|
||||
const String XSL_VENDOR_URL_PROPERTY = "vendor-url";
|
||||
const String XSL_VERSION_PROPERTY("version");
|
||||
const String XSL_VENDOR_PROPERTY("vendor");
|
||||
const String XSL_VENDOR_URL_PROPERTY("vendor-url");
|
||||
|
||||
/*
|
||||
Implementation of XSLT 1.0 extension function: system-property
|
||||
|
|
|
@ -119,8 +119,8 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
int multiplier=1;
|
||||
int groupSize=-1;
|
||||
|
||||
int pos=0;
|
||||
int formatLen = formatStr.length();
|
||||
PRUint32 pos = 0;
|
||||
PRUint32 formatLen = formatStr.length();
|
||||
MBool inQuote;
|
||||
|
||||
// Get right subexpression
|
||||
|
@ -366,17 +366,18 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
if (groupSize < 0)
|
||||
groupSize = intDigits * 2; //to simplify grouping
|
||||
|
||||
res.setLength(res.length() +
|
||||
intDigits + // integer digits
|
||||
1 + // decimal separator
|
||||
maxFractionSize + // fractions
|
||||
(intDigits-1)/groupSize); // group separators
|
||||
// XXX We shouldn't use SetLength.
|
||||
res.getNSString().SetLength(res.length() +
|
||||
intDigits + // integer digits
|
||||
1 + // decimal separator
|
||||
maxFractionSize + // fractions
|
||||
(intDigits-1)/groupSize); // group separators
|
||||
|
||||
PRInt32 i = bufIntDigits + maxFractionSize - 1;
|
||||
MBool carry = (i+1 < buflen) && (buf[i+1] >= '5');
|
||||
MBool hasFraction = MB_FALSE;
|
||||
|
||||
PRInt32 resPos = res.length()-1;
|
||||
PRUint32 resPos = res.length()-1;
|
||||
|
||||
// Fractions
|
||||
for (; i >= bufIntDigits; --i) {
|
||||
|
@ -391,22 +392,23 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
else {
|
||||
digit = buf[i] - '0';
|
||||
}
|
||||
|
||||
if (hasFraction || digit != 0 || i < bufIntDigits+minFractionSize) {
|
||||
hasFraction = MB_TRUE;
|
||||
res.replace(resPos--,
|
||||
(UNICODE_CHAR)(digit + format->mZeroDigit));
|
||||
}
|
||||
else {
|
||||
res.setLength(resPos--);
|
||||
res.truncate(resPos--);
|
||||
}
|
||||
}
|
||||
|
||||
// Decimal separator
|
||||
if (hasFraction)
|
||||
if (hasFraction) {
|
||||
res.replace(resPos--, format->mDecimalSeparator);
|
||||
else
|
||||
res.setLength(resPos--);
|
||||
}
|
||||
else {
|
||||
res.truncate(resPos--);
|
||||
}
|
||||
|
||||
// Integer digits
|
||||
for (i = 0; i < intDigits; ++i) {
|
||||
|
@ -423,15 +425,17 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
carry = digit == 0;
|
||||
}
|
||||
|
||||
if (i != 0 && i%groupSize == 0)
|
||||
if (i != 0 && i%groupSize == 0) {
|
||||
res.replace(resPos--, format->mGroupingSeparator);
|
||||
}
|
||||
|
||||
res.replace(resPos--, (UNICODE_CHAR)(digit + format->mZeroDigit));
|
||||
}
|
||||
|
||||
if (carry) {
|
||||
if (i%groupSize == 0)
|
||||
if (i%groupSize == 0) {
|
||||
res.insert(resPos + 1, format->mGroupingSeparator);
|
||||
}
|
||||
res.insert(resPos + 1, (UNICODE_CHAR)(1 + format->mZeroDigit));
|
||||
}
|
||||
|
||||
|
@ -451,13 +455,12 @@ ExprResult* txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext)
|
|||
* A representation of the XSLT element <xsl:decimal-format>
|
||||
*/
|
||||
|
||||
txDecimalFormat::txDecimalFormat()
|
||||
txDecimalFormat::txDecimalFormat() : mInfinity("Infinity"),
|
||||
mNaN("NaN")
|
||||
{
|
||||
mDecimalSeparator = '.';
|
||||
mGroupingSeparator = ',';
|
||||
mInfinity = "Infinity";
|
||||
mMinusSign = '-';
|
||||
mNaN = "NaN";
|
||||
mPercent = '%';
|
||||
mPerMille = 0x2030;
|
||||
mZeroDigit = '0';
|
||||
|
|
|
@ -188,7 +188,7 @@ void txHTMLOutput::attribute(const String& aName,
|
|||
}
|
||||
}
|
||||
if (!setAtt) {
|
||||
setAtt = new txAttribute(aNsID, localName, "");
|
||||
setAtt = new txAttribute(aNsID, localName, String());
|
||||
setAtt->mShorthand = MB_TRUE;
|
||||
mAttributes.add(setAtt);
|
||||
}
|
||||
|
|
|
@ -116,10 +116,10 @@ void txOutputFormat::setFromDefaults()
|
|||
case eXMLOutput:
|
||||
{
|
||||
if (mVersion.isEmpty())
|
||||
mVersion = "1.0";
|
||||
mVersion.append("1.0");
|
||||
|
||||
if (mEncoding.isEmpty())
|
||||
mEncoding = "UTF-8";
|
||||
mEncoding.append("UTF-8");
|
||||
|
||||
if (mOmitXMLDeclaration == eNotSet)
|
||||
mOmitXMLDeclaration = eFalse;
|
||||
|
@ -128,33 +128,33 @@ void txOutputFormat::setFromDefaults()
|
|||
mIndent = eFalse;
|
||||
|
||||
if (mMediaType.isEmpty())
|
||||
mMediaType = "text/xml";
|
||||
mMediaType.append("text/xml");
|
||||
|
||||
break;
|
||||
}
|
||||
case eHTMLOutput:
|
||||
{
|
||||
if (mVersion.isEmpty())
|
||||
mVersion = "4.0";
|
||||
mVersion.append("4.0");
|
||||
|
||||
if (mEncoding.isEmpty())
|
||||
mEncoding = "UTF-8";
|
||||
mEncoding.append("UTF-8");
|
||||
|
||||
if (mIndent == eNotSet)
|
||||
mIndent = eTrue;
|
||||
|
||||
if (mMediaType.isEmpty())
|
||||
mMediaType = "text/html";
|
||||
mMediaType.append("text/html");
|
||||
|
||||
break;
|
||||
}
|
||||
case eTextOutput:
|
||||
{
|
||||
if (mEncoding.isEmpty())
|
||||
mEncoding = "UTF-8";
|
||||
mEncoding.append("UTF-8");
|
||||
|
||||
if (mMediaType.isEmpty())
|
||||
mMediaType = "text/plain";
|
||||
mMediaType.append("text/plain");
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -93,9 +93,9 @@ void txXMLOutput::characters(const String& aData)
|
|||
closeStartTag(MB_FALSE);
|
||||
|
||||
if (mInCDATASection) {
|
||||
PRInt32 i = 0;
|
||||
PRInt32 j = 0;
|
||||
PRInt32 length = aData.length();
|
||||
PRUint32 i = 0;
|
||||
PRUint32 j = 0;
|
||||
PRUint32 length = aData.length();
|
||||
|
||||
*mOut << CDATA_START;
|
||||
|
||||
|
@ -317,7 +317,7 @@ void txXMLOutput::printUTF8Char(DOM_CHAR& ch)
|
|||
void txXMLOutput::printUTF8Chars(const String& aData)
|
||||
{
|
||||
DOM_CHAR currChar;
|
||||
PRInt32 i = 0;
|
||||
PRUint32 i = 0;
|
||||
|
||||
while (i < aData.length()) {
|
||||
currChar = aData.charAt(i++);
|
||||
|
@ -329,7 +329,7 @@ void txXMLOutput::printWithXMLEntities(const String& aData,
|
|||
MBool aAttribute)
|
||||
{
|
||||
DOM_CHAR currChar;
|
||||
PRInt32 i;
|
||||
PRUint32 i;
|
||||
|
||||
if (&aData == &NULL_STRING)
|
||||
return;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsReadableUtils.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "XMLUtils.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -317,8 +318,6 @@ void txRootPattern::toString(String& aDest)
|
|||
* argument.
|
||||
*/
|
||||
|
||||
#define TX_IS_WHITE(c) (c == ' ' || c == '\r' || c == '\n'|| c == '\t')
|
||||
|
||||
txIdPattern::txIdPattern(const String aString)
|
||||
{
|
||||
#ifdef TX_EXE
|
||||
|
@ -330,12 +329,12 @@ txIdPattern::txIdPattern(const String aString)
|
|||
ids.EndReading(end);
|
||||
pos = begin;
|
||||
while (pos != end) {
|
||||
while (pos != end && TX_IS_WHITE(*pos))
|
||||
while (pos != end && XMLUtils::isWhitespace(*pos))
|
||||
++pos;
|
||||
begin = pos;
|
||||
if (!mIds.IsEmpty())
|
||||
mIds += PRUnichar(' ');
|
||||
while (pos != end && !TX_IS_WHITE(*pos))
|
||||
while (pos != end && !XMLUtils::isWhitespace(*pos))
|
||||
++pos;
|
||||
mIds += Substring(begin, pos);
|
||||
}
|
||||
|
@ -413,7 +412,7 @@ void txIdPattern::toString(String& aDest)
|
|||
#ifdef TX_EXE
|
||||
aDest.append(mIds);
|
||||
#else
|
||||
aDest.append(mIds.get());
|
||||
aDest.getNSString().Append(mIds);
|
||||
#endif
|
||||
aDest.append("')");
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -122,7 +122,7 @@ MBool txNodeSorter::addSortElement(Element* aSortElement,
|
|||
// Language
|
||||
String lang;
|
||||
if (!getAttrAsAVT(aSortElement, txXSLTAtoms::lang, aContext, lang))
|
||||
lang = DEFAULT_LANG;
|
||||
lang.append(DEFAULT_LANG);
|
||||
|
||||
// Case-order
|
||||
MBool upperFirst;
|
||||
|
|
|
@ -143,11 +143,11 @@ int txResultStringComparator::compareValues(TxObject* aVal1, TxObject* aVal2)
|
|||
StringValue* strval1 = (StringValue*)aVal1;
|
||||
StringValue* strval2 = (StringValue*)aVal2;
|
||||
#ifdef TX_EXE
|
||||
PRInt32 len1 = strval1->mStr.length();
|
||||
PRInt32 len2 = strval2->mStr.length();
|
||||
PRInt32 minLength = (len1 < len2) ? len1 : len2;
|
||||
PRUint32 len1 = strval1->mStr.length();
|
||||
PRUint32 len2 = strval2->mStr.length();
|
||||
PRUint32 minLength = (len1 < len2) ? len1 : len2;
|
||||
|
||||
PRInt32 c = 0;
|
||||
PRUint32 c = 0;
|
||||
while (c < minLength) {
|
||||
UNICODE_CHAR ch1 = strval1->mStr.charAt(c);
|
||||
UNICODE_CHAR ch2 = strval2->mStr.charAt(c);
|
||||
|
|
Загрузка…
Ссылка в новой задаче