diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/xslt/xml/txXMLUtils.h | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/xslt/xml/txXMLUtils.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/dom/xslt/xml/txXMLUtils.h b/dom/xslt/xml/txXMLUtils.h new file mode 100644 index 0000000000..e7723fbaca --- /dev/null +++ b/dom/xslt/xml/txXMLUtils.h @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/** + * An XML Utility class + **/ + +#ifndef MITRE_XMLUTILS_H +#define MITRE_XMLUTILS_H + +#include "txCore.h" +#include "nsDependentSubstring.h" +#include "txXPathNode.h" + +#define kExpatSeparatorChar 0xFFFF + +extern "C" int MOZ_XMLIsLetter(const char* ptr); +extern "C" int MOZ_XMLIsNCNameChar(const char* ptr); + +class nsAtom; + +class XMLUtils { + public: + static nsresult splitExpatName(const char16_t* aExpatName, nsAtom** aPrefix, + nsAtom** aLocalName, int32_t* aNameSpaceID); + static nsresult splitQName(const nsAString& aName, nsAtom** aPrefix, + nsAtom** aLocalName); + + /* + * Returns true if the given character is whitespace. + */ + static bool isWhitespace(const char16_t& aChar) { + return (aChar <= ' ' && + (aChar == ' ' || aChar == '\r' || aChar == '\n' || aChar == '\t')); + } + + /** + * Returns true if the given string has only whitespace characters + */ + static bool isWhitespace(const nsAString& aText); + + /** + * Normalizes the value of a XML processingInstruction + **/ + static void normalizePIValue(nsAString& attValue); + + /** + * Returns true if the given string is a valid XML QName + */ + static bool isValidQName(const nsAString& aQName, const char16_t** aColon); + + /** + * Returns true if the given character represents an Alpha letter + */ + static bool isLetter(char16_t aChar) { + return !!MOZ_XMLIsLetter(reinterpret_cast<const char*>(&aChar)); + } + + /** + * Returns true if the given character is an allowable NCName character + */ + static bool isNCNameChar(char16_t aChar) { + return !!MOZ_XMLIsNCNameChar(reinterpret_cast<const char*>(&aChar)); + } + + /* + * Walks up the document tree and returns true if the closest xml:space + * attribute is "preserve" + */ + static bool getXMLSpacePreserve(const txXPathNode& aNode); +}; + +#endif |