You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/05/08 19:29:47 UTC
cvs commit: xml-xalan/c/src/XSLT ElemDecimalFormat.hpp ElemNumber.cpp ElemNumber.hpp FunctionFormatNumber.cpp FunctionFormatNumber.hpp Stylesheet.cpp Stylesheet.hpp StylesheetExecutionContext.hpp StylesheetExecutionContextDefault.cpp StylesheetExecutionContextDefault.hpp StylesheetHandler.cpp XSLTEngineImpl.cpp XSLTInputSource.cpp
dbertoni 00/05/08 10:29:46
Modified: c/src/XSLT ElemDecimalFormat.hpp ElemNumber.cpp
ElemNumber.hpp FunctionFormatNumber.cpp
FunctionFormatNumber.hpp Stylesheet.cpp
Stylesheet.hpp StylesheetExecutionContext.hpp
StylesheetExecutionContextDefault.cpp
StylesheetExecutionContextDefault.hpp
StylesheetHandler.cpp XSLTEngineImpl.cpp
XSLTInputSource.cpp
Log:
Changes for ICU integration and fixes for import/include and relative URIs.
Revision Changes Path
1.3 +7 -7 xml-xalan/c/src/XSLT/ElemDecimalFormat.hpp
Index: ElemDecimalFormat.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemDecimalFormat.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ElemDecimalFormat.hpp 2000/04/19 17:32:27 1.2
+++ ElemDecimalFormat.hpp 2000/05/08 17:29:34 1.3
@@ -69,7 +69,7 @@
-#include <PlatformSupport/DecimalFormatSymbols.hpp>
+#include <PlatformSupport/XalanDecimalFormatSymbols.hpp>
@@ -110,7 +110,7 @@
XalanNode* sourceNode,
const QName& mode) const;
- const DecimalFormatSymbols&
+ const XalanDecimalFormatSymbols&
getDecimalFormatSymbols() const
{
return m_decimalFormatSymbols;
@@ -124,13 +124,13 @@
private:
- const XPath* m_countMatchPattern;
- const XPath* m_fromMatchPattern;
- const XPath* m_valueExpr;
+ const XPath* m_countMatchPattern;
+ const XPath* m_fromMatchPattern;
+ const XPath* m_valueExpr;
- XalanDOMString m_name_avt;
+ XalanDOMString m_name_avt;
- DecimalFormatSymbols m_decimalFormatSymbols;
+ XalanDecimalFormatSymbols m_decimalFormatSymbols;
};
1.16 +8 -8 xml-xalan/c/src/XSLT/ElemNumber.cpp
Index: ElemNumber.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ElemNumber.cpp 2000/05/01 16:41:11 1.15
+++ ElemNumber.cpp 2000/05/08 17:29:34 1.16
@@ -67,7 +67,7 @@
#include <PlatformSupport/DOMStringHelper.hpp>
-#include <PlatformSupport/NumberFormat.hpp>
+#include <PlatformSupport/XalanNumberFormat.hpp>
@@ -576,17 +576,17 @@
#endif
-NumberFormat*
+XalanNumberFormat*
ElemNumber::getNumberFormatter(
StylesheetExecutionContext& executionContext,
XalanNode* contextNode) const
{
#if ! defined(__GNUC__)
- std::locale loc = getLocale(executionContext, contextNode);
+// std::locale loc = getLocale(executionContext, contextNode);
#endif
-
+
// Helper to format local specific numbers to strings.
- std::auto_ptr<NumberFormat> formatter(new NumberFormat);
+ std::auto_ptr<XalanNumberFormat> formatter(executionContext.createXalanNumberFormat());
XalanDOMString digitGroupSepValue;
if (0 != m_groupingSeparator_avt)
@@ -604,7 +604,7 @@
{
formatter->setGroupingUsed(true);
formatter->setGroupingSeparator(digitGroupSepValue);
- formatter->setGroupingSize(nDigitsPerGroupValue);
+ formatter->setGroupingSize(DOMStringToUnsignedLong(nDigitsPerGroupValue));
}
return formatter.release();
@@ -642,7 +642,7 @@
NumberFormatStringTokenizer formatTokenizer(formatValue);
#if ! defined(__GNUC__)
- std::locale loc = getLocale(executionContext, contextNode);
+// std::locale loc = getLocale(executionContext, contextNode);
#endif
typedef vector<XalanDOMString> StringVectorType;
@@ -713,7 +713,7 @@
int listElement) const
{
- std::auto_ptr<NumberFormat> formatter(
+ StylesheetExecutionContext::XalanNumberFormatAutoPtr formatter(
getNumberFormatter(executionContext, contextNode));
XalanDOMString padString = formatter->format(0);
1.13 +3 -3 xml-xalan/c/src/XSLT/ElemNumber.hpp
Index: ElemNumber.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ElemNumber.hpp 2000/05/01 16:41:11 1.12
+++ ElemNumber.hpp 2000/05/08 17:29:34 1.13
@@ -58,7 +58,7 @@
#define XALAN_ELEMNUMBER_HEADER_GUARD
/**
- * $Id: ElemNumber.hpp,v 1.12 2000/05/01 16:41:11 dbertoni Exp $
+ * $Id: ElemNumber.hpp,v 1.13 2000/05/08 17:29:34 dbertoni Exp $
*
* $State: Exp $
*
@@ -89,8 +89,8 @@
-class NumberFormat;
class QName;
+class XalanNumberFormat;
class XPath;
class XPathExecutionContext;
@@ -238,7 +238,7 @@
XalanNode* contextNode) const;
#endif
- NumberFormat*
+ XalanNumberFormat*
getNumberFormatter(
StylesheetExecutionContext& executionContext,
XalanNode* contextNode) const;
1.3 +34 -19 xml-xalan/c/src/XSLT/FunctionFormatNumber.cpp
Index: FunctionFormatNumber.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionFormatNumber.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FunctionFormatNumber.cpp 2000/04/11 15:09:27 1.2
+++ FunctionFormatNumber.cpp 2000/05/08 17:29:35 1.3
@@ -58,12 +58,8 @@
-#include <dom/DOMString.hpp>
-
-
-
-#include <PlatformSupport/DecimalFormat.hpp>
-#include <PlatformSupport/DecimalFormatSymbols.hpp>
+#include <PlatformSupport/XalanDecimalFormat.hpp>
+#include <PlatformSupport/XalanDecimalFormatSymbols.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
@@ -109,20 +105,15 @@
}
else
{
- executionContext.warn(XALAN_STATIC_UCODE_STRING("format-number() is not fully implemented!"),
- context);
-
assert(args[0] != 0);
assert(args[1] != 0);
assert(theSize == 2 || args[2] != 0);
- DecimalFormat theFormatter;
+ const double theNumber = args[0]->num();
+ const XalanDOMString thePattern = args[1]->str();
- const double theNumber = args[0]->num();
- const XalanDOMString theFormatString = args[1]->str();
+ const XalanDecimalFormatSymbols* theDFS = 0;
- const DecimalFormatSymbols* theDFS = 0;
-
if (theSize == 3)
{
const XalanDOMString theDecimalFormatName = args[2]->str();
@@ -141,13 +132,15 @@
{
theDFS = executionContext.getDecimalFormatSymbols(Constants::DEFAULT_DECIMAL_FORMAT);
}
-
- theFormatter.setDecimalFormatSymbols(theDFS == 0 ? DecimalFormatSymbols() : *theDFS);
- theFormatter.applyLocalizedPattern(theFormatString);
+ const XalanDOMString theString = doFormat(
+ executionContext,
+ context,
+ theNumber,
+ thePattern,
+ theDFS);
- // $$$ ToDo: This is not really working according to the spec.
- return executionContext.getXObjectFactory().createString(theFormatter.format(theNumber));
+ return executionContext.getXObjectFactory().createString(theString);
}
}
@@ -161,4 +154,26 @@
FunctionFormatNumber::clone() const
{
return new FunctionFormatNumber(*this);
+}
+
+
+
+XalanDOMString
+FunctionFormatNumber::doFormat(
+ XPathExecutionContext& executionContext,
+ XalanNode* context,
+ double theNumber,
+ const XalanDOMString& thePattern,
+ const XalanDecimalFormatSymbols* theDFS)
+{
+ executionContext.warn(XALAN_STATIC_UCODE_STRING("format-number() is not fully implemented!"),
+ context);
+
+ XalanDecimalFormat theFormatter;
+
+ theFormatter.setDecimalFormatSymbols(theDFS != 0 ? *theDFS : XalanDecimalFormatSymbols());
+
+ theFormatter.applyLocalizedPattern(thePattern);
+
+ return theFormatter.format(theNumber);
}
1.5 +15 -0 xml-xalan/c/src/XSLT/FunctionFormatNumber.hpp
Index: FunctionFormatNumber.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionFormatNumber.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FunctionFormatNumber.hpp 2000/04/18 15:27:52 1.4
+++ FunctionFormatNumber.hpp 2000/05/08 17:29:35 1.5
@@ -68,10 +68,15 @@
+#include <XalanDOM/XalanDOMString.hpp>
+
+
+
#include <XPath/Function.hpp>
+class XalanDecimalFormatSymbols;
class XObject;
class XPathExecutionContext;
@@ -103,6 +108,16 @@
virtual FunctionFormatNumber*
#endif
clone() const;
+
+protected:
+
+ virtual XalanDOMString
+ doFormat(
+ XPathExecutionContext& executionContext,
+ XalanNode* context,
+ double theNumber,
+ const XalanDOMString& thePattern,
+ const XalanDecimalFormatSymbols* theDFS);
private:
1.15 +2 -2 xml-xalan/c/src/XSLT/Stylesheet.cpp
Index: Stylesheet.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Stylesheet.cpp 2000/05/01 15:13:10 1.14
+++ Stylesheet.cpp 2000/05/08 17:29:35 1.15
@@ -1213,10 +1213,10 @@
-const DecimalFormatSymbols*
+const XalanDecimalFormatSymbols*
Stylesheet::getDecimalFormatSymbols(const XalanDOMString& name) const
{
- const DecimalFormatSymbols* dfs = 0;
+ const XalanDecimalFormatSymbols* dfs = 0;
const ElemDecimalFormatVectorType::size_type theSize =
m_elemDecimalFormats.size();
1.11 +3 -3 xml-xalan/c/src/XSLT/Stylesheet.hpp
Index: Stylesheet.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Stylesheet.hpp 2000/05/01 15:13:10 1.10
+++ Stylesheet.hpp 2000/05/08 17:29:35 1.11
@@ -92,7 +92,7 @@
class AttributeList;
class ExtensionNSHandler;
-class DecimalFormatSymbols;
+class XalanDecimalFormatSymbols;
class ElemAttributeSet;
class ElemDecimalFormat;
class ElemTemplate;
@@ -391,13 +391,13 @@
StylesheetConstructionContext& constructionContext);
/**
- * Retrieve the DecimalFormatSymbols instance associated with
+ * Retrieve the XalanDecimalFormatSymbols instance associated with
* the name.
*
* @param name the name for the lookup
* @return a pointer to the matching instance, or 0 if none was found
*/
- const DecimalFormatSymbols*
+ const XalanDecimalFormatSymbols*
getDecimalFormatSymbols(const XalanDOMString& name) const;
/**
1.11 +20 -3 xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp
Index: StylesheetExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- StylesheetExecutionContext.hpp 2000/05/01 15:13:10 1.10
+++ StylesheetExecutionContext.hpp 2000/05/08 17:29:35 1.11
@@ -66,8 +66,8 @@
-// std stream forward declarations.
#include <iosfwd>
+#include <memory>
@@ -98,9 +98,10 @@
class Stylesheet;
class StylesheetRoot;
class TextOutputStream;
+class XalanDocument;
class XalanElement;
class XalanNode;
-class XalanDocument;
+class XalanNumberFormat;
class XPath;
class XObject;
@@ -914,6 +915,22 @@
StylesheetExecutionContext& m_executionContext;
};
+
+#if defined(XALAN_NO_NAMESPACES)
+ typedef auto_ptr<XalanNumberFormat> XalanNumberFormatAutoPtr;
+#else
+ typedef std::auto_ptr<XalanNumberFormat> XalanNumberFormatAutoPtr;
+#endif
+
+ /**
+ * Create a new XalanNumberFormat instance.
+ *
+ * @return an auto_ptr that owns a new XalanNumberFormat instance.
+ */
+ virtual XalanNumberFormatAutoPtr
+ createXalanNumberFormat() = 0;
+
+
// These interfaces are inherited from XPathExecutionContext...
virtual XalanNode*
@@ -1059,7 +1076,7 @@
XalanDocument* theDocument) = 0;
- virtual const DecimalFormatSymbols*
+ virtual const XalanDecimalFormatSymbols*
getDecimalFormatSymbols(const XalanDOMString& name) = 0;
virtual PrintWriter*
1.9 +58 -1 xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
Index: StylesheetExecutionContextDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StylesheetExecutionContextDefault.cpp 2000/05/01 15:13:10 1.8
+++ StylesheetExecutionContextDefault.cpp 2000/05/08 17:29:35 1.9
@@ -68,6 +68,7 @@
#include <PlatformSupport/STLHelper.hpp>
#include <PlatformSupport/TextOutputStream.hpp>
+#include <PlatformSupport/XalanNumberFormat.hpp>
@@ -94,6 +95,13 @@
+StylesheetExecutionContextDefault::XalanNumberFormatFactory StylesheetExecutionContextDefault::s_defaultXalanNumberFormatFactory;
+
+StylesheetExecutionContextDefault::XalanNumberFormatFactory* StylesheetExecutionContextDefault::s_xalanNumberFormatFactory =
+ &StylesheetExecutionContextDefault::getDefaultXalanNumberFormatFactory();
+
+
+
StylesheetExecutionContextDefault::StylesheetExecutionContextDefault(
XSLTEngineImpl& xsltProcessor,
XPathEnvSupport& theXPathEnvSupport,
@@ -724,6 +732,55 @@
+StylesheetExecutionContextDefault::XalanNumberFormatAutoPtr
+StylesheetExecutionContextDefault::createXalanNumberFormat()
+{
+ return XalanNumberFormatAutoPtr(s_xalanNumberFormatFactory->create());
+}
+
+
+
+StylesheetExecutionContextDefault::XalanNumberFormatFactory::XalanNumberFormatFactory()
+{
+}
+
+
+
+StylesheetExecutionContextDefault::XalanNumberFormatFactory::~XalanNumberFormatFactory()
+{
+}
+
+
+
+XalanNumberFormat*
+StylesheetExecutionContextDefault::XalanNumberFormatFactory::create()
+{
+ return new XalanNumberFormat();
+}
+
+
+
+StylesheetExecutionContextDefault::XalanNumberFormatFactory*
+StylesheetExecutionContextDefault::installXalanNumberFormatFactory(XalanNumberFormatFactory* theFactory)
+{
+ XalanNumberFormatFactory* const theOldFactory =
+ s_xalanNumberFormatFactory;
+
+ if (theFactory == 0)
+ {
+ s_xalanNumberFormatFactory = &s_defaultXalanNumberFormatFactory;
+ }
+ else
+ {
+ s_xalanNumberFormatFactory = theFactory;
+ }
+
+ return theOldFactory;
+}
+
+
+
+
XalanNode*
StylesheetExecutionContextDefault::getCurrentNode() const
{
@@ -1051,7 +1108,7 @@
-const DecimalFormatSymbols*
+const XalanDecimalFormatSymbols*
StylesheetExecutionContextDefault::getDecimalFormatSymbols(const XalanDOMString& name)
{
if (m_stylesheetRoot == 0)
1.10 +45 -6 xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
Index: StylesheetExecutionContextDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- StylesheetExecutionContextDefault.hpp 2000/05/01 15:13:10 1.9
+++ StylesheetExecutionContextDefault.hpp 2000/05/08 17:29:36 1.10
@@ -335,7 +335,42 @@
virtual const ElemTemplateElement*
popElementRecursionStack();
+ virtual XalanNumberFormatAutoPtr
+ createXalanNumberFormat();
+
+ // A basic class to create XalanNumberFormat instances...
+ class XALAN_XSLT_EXPORT XalanNumberFormatFactory
+ {
+ public:
+
+ explicit
+ XalanNumberFormatFactory();
+
+ virtual
+ ~XalanNumberFormatFactory();
+
+ virtual XalanNumberFormat*
+ create();
+ };
+
+ static XalanNumberFormatFactory&
+ getDefaultXalanNumberFormatFactory()
+ {
+ return s_defaultXalanNumberFormatFactory;
+ }
+
+ /**
+ * Static function to install a new XalanNumberFormatFactory.
+ * The caller owns the XalanNumberFormatFactory instance.
+ *
+ * @param a pointer to the new factory instance to use.
+ * @return a pointer to the old factory instance.
+ */
+ //
+ static XalanNumberFormatFactory*
+ installXalanNumberFormatFactory(XalanNumberFormatFactory* theFactory);
+
// These interfaces are inherited from XPathExecutionContext...
virtual XalanNode*
@@ -481,7 +516,7 @@
XalanDocument* theDocument);
- virtual const DecimalFormatSymbols*
+ virtual const XalanDecimalFormatSymbols*
getDecimalFormatSymbols(const XalanDOMString& name);
virtual PrintWriter*
@@ -535,16 +570,20 @@
typedef std::set<PrintWriter*> PrintWriterSetType;
typedef std::set<TextOutputStream*> TextOutputStreamSetType;
#endif
+
+ ElementRecursionStackType m_elementRecursionStack;
+
+ const PrefixResolver* m_prefixResolver;
- ElementRecursionStackType m_elementRecursionStack;
+ StylesheetRoot* m_stylesheetRoot;
- const PrefixResolver* m_prefixResolver;
+ PrintWriterSetType m_printWriters;
- StylesheetRoot* m_stylesheetRoot;
+ TextOutputStreamSetType m_textOutputStreams;
- PrintWriterSetType m_printWriters;
+ static XalanNumberFormatFactory s_defaultXalanNumberFormatFactory;
- TextOutputStreamSetType m_textOutputStreams;
+ static XalanNumberFormatFactory* s_xalanNumberFormatFactory;
};
1.23 +9 -4 xml-xalan/c/src/XSLT/StylesheetHandler.cpp
Index: StylesheetHandler.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- StylesheetHandler.cpp 2000/05/01 15:13:10 1.22
+++ StylesheetHandler.cpp 2000/05/08 17:29:36 1.23
@@ -1106,10 +1106,13 @@
const XalanDOMString href = atts.getValue(i);
- const XMLURL* const hrefUrl = m_processor.getURLFromString(href, m_stylesheet.getBaseIdentifier());
+ Stylesheet::URLStackType& includeStack = m_stylesheet.getIncludeStack();
+ assert(includeStack.size() > 0);
+
+ const XMLURL* const hrefUrl = m_processor.getURLFromString(href, includeStack.back()->getURLText());
assert(hrefUrl != 0);
- StylesheetRoot::URLStackType& importStack = m_stylesheet.getStylesheetRoot().getImportStack();
+ Stylesheet::URLStackType& importStack = m_stylesheet.getStylesheetRoot().getImportStack();
if(stackContains(importStack, *hrefUrl))
{
@@ -1120,14 +1123,16 @@
importStack.push_back(hrefUrl);
+ const XalanDOMString theImportURI(hrefUrl->getURLText());
+
Stylesheet* pImportedStylesheet = new Stylesheet(
m_stylesheet.getStylesheetRoot(),
- m_stylesheet.getBaseIdentifier(),
+ theImportURI,
m_constructionContext);
StylesheetHandler tp(m_processor, *pImportedStylesheet, m_constructionContext);
- pImportedStylesheet->setBaseIdentifier(hrefUrl->getURLText());
+// pImportedStylesheet->setBaseIdentifier();
m_processor.parseXML(*hrefUrl, &tp, pImportedStylesheet);
1.32 +179 -44 xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp
Index: XSLTEngineImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- XSLTEngineImpl.cpp 2000/05/01 15:13:10 1.31
+++ XSLTEngineImpl.cpp 2000/05/08 17:29:36 1.32
@@ -517,12 +517,14 @@
#if !defined(XALAN_NO_NAMESPACES)
using std::auto_ptr;
#endif
-
+#if 0
auto_ptr<XMLURL> url(getURLFromString(xsldocURLString));
assert(url.get() != 0);
XSLTInputSource input(url->getURLText(), 0);
-
+#else
+ XSLTInputSource input(c_wstr(xsldocURLString));
+#endif
return processStylesheet(input, constructionContext);
}
catch(SAXException& se)
@@ -921,8 +923,6 @@
const XalanDOMString localName =
m_xpathSupport.getLocalNameOfNode(node);
- // $$$ ToDo: Why can't this iterator be a
- // const_iterator? VC++ pukes if it is.
const ElementKeysMapType::const_iterator j =
s_elementKeys.find(localName);
if(j != s_elementKeys.end())
@@ -961,16 +961,8 @@
void
-XSLTEngineImpl::outputToResultTree(
- const XObject& value)
+XSLTEngineImpl::outputToResultTree(const XObject& value)
{
- // java:
- // Make the return object into an XObject because it
- // will be easier below. One of the reasons to do this
- // is to keep all the conversion functionality in the
- // XObject classes.
- // JMD: Has to be an XObject
-
const int type = value.getType();
XalanDOMString s;
@@ -1040,6 +1032,7 @@
case XObject::eTypeResultTreeFrag:
outputResultTreeFragment(value);
break;
+
case XObject::eTypeNull:
case XObject::eTypeUnknown:
case XObject::eUnknown:
@@ -1539,16 +1532,33 @@
const XalanDOMString& aname,
const XalanDOMString& value)
{
- assert(length(value) > 0);
-
const bool isPrefix = startsWith(aname, DOMServices::s_XMLNamespaceWithSeparator);
+
if (equals(aname, DOMServices::s_XMLNamespace) || isPrefix == true)
{
const XalanDOMString p = isPrefix == true ? substring(aname, 6) : XalanDOMString();
addResultNamespaceDecl(p, value);
}
+
attList.removeAttribute(c_wstr(aname));
- attList.addAttribute(c_wstr(aname), c_wstr(XALAN_STATIC_UCODE_STRING("CDATA")), c_wstr(value));
+
+ if (length(value) > 0)
+ {
+ attList.addAttribute(
+ c_wstr(aname),
+ c_wstr(XALAN_STATIC_UCODE_STRING("CDATA")),
+ c_wstr(value));
+ }
+ else
+ {
+ const XMLCh theDummy = 0;
+
+ attList.addAttribute(
+ c_wstr(aname),
+ c_wstr(XALAN_STATIC_UCODE_STRING("CDATA")),
+ &theDummy);
+ }
+
}
@@ -3562,7 +3572,7 @@
XMLURL*
-XSLTEngineImpl::getURLFromString (const XalanDOMString& urlString) const
+XSLTEngineImpl::getURLFromString(const XalanDOMString& urlString) const
{
#if !defined(XALAN_NO_NAMESPACES)
using std::auto_ptr;
@@ -3572,62 +3582,187 @@
try
{
- url->setURL(c_wstr(urlString));
- }
- // 'urlString' not a valid url, try to construct a file url
- catch (const MalformedURLException&)
- {
- XalanDOMString fullpath("file:///");
+ // Let's see what sort of URI we have...
+ const unsigned int index = indexOf(urlString, ':');
- try
+ if (index == 1 || index == length(urlString))
{
-// XMLCh* lastPart = XMLPlatformUtils::getBasePath(c_wstr(urlString));
-// fullpath += lastPart;
+ // OK, it's some sort of file specification,
+ // so prepend "file:///"
+ XalanDOMString fullpath("file:///");
+
fullpath += urlString;
+
url->setURL(c_wstr(fullpath));
}
- catch (MalformedURLException& e2)
+ else
{
- diag("Error! Cannot create url for: " + fullpath);
- throw e2;
+ // OK, assume it's already got a protocol
+ url->setURL(c_wstr(urlString));
}
}
+ catch (...)
+ {
+ diag("Error! Cannot create url for: " + urlString);
+
+ throw;
+ }
return url.release();
}
+XalanDOMString
+NormalizeURI(
+ const XalanDOMString& uriString,
+ XalanDOMChar theOldSeparator,
+ XalanDOMChar theNewSeparator)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::vector;
+#endif
+
+ vector<XalanDOMChar> theBuffer;
+
+ const unsigned int theLength = length(uriString);
+
+ // Reserve enough characters in the buffer...
+ theBuffer.reserve(theLength);
+
+ // See if we have a hybrid DOS-style URI, like
+ // file:///c:\foo\foo.xml
+ const unsigned int i1 = indexOf(uriString, ':');
+ const unsigned int i2 = lastIndexOf(uriString, ':');
+
+ bool fHybrid = i1 == i2 ? false : true;
+ assert(fHybrid == false || theNewSeparator == '\\');
+
+ for(unsigned int i = 0; i < theLength; ++i)
+ {
+ const XalanDOMChar theChar = charAt(uriString, i);
+
+ if (fHybrid == true)
+ {
+ if (theChar == theOldSeparator && i > i2)
+ {
+ theBuffer.push_back(theNewSeparator);
+ }
+ else
+ {
+ theBuffer.push_back(theChar);
+ }
+ }
+ else if (theChar == theOldSeparator)
+ {
+ theBuffer.push_back(theNewSeparator);
+ }
+ else
+ {
+ theBuffer.push_back(theChar);
+ }
+ }
+
+ return XalanDOMString(&theBuffer[0], theBuffer.size());
+}
+
+
+
XMLURL* XSLTEngineImpl::getURLFromString(const XalanDOMString& urlString, const XalanDOMString& base) const
{
- if (isEmpty(base))
- return getURLFromString(urlString);
+ XalanDOMString context;
+
+ bool fNormalizeToSlash = false;
+ bool fNormalizeToBackslash = false;
+
+ if (isEmpty(base) == false)
+ {
+ // We'll only do the really simple case for now:
+ // base is a complete file URL and urlString is a forward relative path, i.e.
+ // in the same directory as the urlString or a subdirectory
+
+ // just to be robust, we'll accept a forward or back slash
+ const unsigned int theLength = length(base);
+
+ const unsigned int i1 = lastIndexOf(base,'/');
+ const unsigned int i2 = lastIndexOf(base,'\\');
+
+ unsigned int i = 0;
+
+ if (i1 > i2 && i1 < theLength)
+ {
+ i = i1;
+
+ fNormalizeToSlash = true;
+ }
+ else if (i2 < theLength)
+ {
+ i = i2;
+
+ fNormalizeToBackslash = true;
+ }
+ else
+ {
+ i = i1;
- // We'll only do the really simple case for now:
- // base is a complete file URL and urlString is a forward relative path, i.e.
- // in the same directory as the urlString or a subdirectory
+ assert(i2 == theLength);
+ }
- XalanDOMString context;
+ if (i < theLength)
+ {
+ context = substring(base, 0, i + 1);
+ }
+ }
- // just to be robust, we'll accept a forward or back slash
- const unsigned int theLength = length(base);
+ // OK, now let's look at the urlString...
- const unsigned int i1 = lastIndexOf(base,'/');
- const unsigned int i2 = lastIndexOf(base,'\\');
+ // Is there a colon, indicating some sort of drive spec, or protocol?
+ const unsigned int theLength = length(urlString);
+ const unsigned int theColonIndex = indexOf(urlString, ':');
- const unsigned int i = i1 > i2 && i1 < theLength ? i1 : i2 < theLength ? i2 : i1;
+ if (theColonIndex == theLength)
+ {
+ // No colon, so just use the urlString as is...
+ context += urlString;
+ }
+ else if (theColonIndex == 1)
+ {
+ // Ahh, it's a drive letter, so ignore the context...
+ context = urlString;
+ }
+ else
+ {
+ // Assume it's a protocol...
+ const XalanDOMString theProtocol(substring(urlString, 0, theColonIndex));
- if (i < theLength)
- context = substring(base, 0, i + 1);
+ if (startsWith(context, theProtocol) == true)
+ {
+ // OK, everything looks good, so strip off the protocol and colon...
+ context += substring(urlString, theColonIndex + 1, theLength);
+ }
+ else
+ {
+ // OK, not the same protocol, so what can we do???
+ context = urlString;
+ }
+ }
- context += urlString;
+ if (fNormalizeToSlash == true)
+ {
+ context = NormalizeURI(context, '\\', '/');
+ }
+ else if (fNormalizeToBackslash == true)
+ {
+ context = NormalizeURI(context, '/', '\\');
+ }
return getURLFromString(context);
}
+
void
-XSLTEngineImpl::setFormatter(Formatter* formatter)
+XSLTEngineImpl::setFormatter(Formatter* formatter)
{
flushPending();
1.6 +1 -1 xml-xalan/c/src/XSLT/XSLTInputSource.cpp
Index: XSLTInputSource.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTInputSource.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XSLTInputSource.cpp 2000/04/25 19:54:18 1.5
+++ XSLTInputSource.cpp 2000/05/08 17:29:36 1.6
@@ -176,7 +176,7 @@
// It could be a DOS-style file spec...
const unsigned int theBackslashIndex = indexOf(theSystemID, '\\');
- if (theBackslashIndex < theLength && theBackslashIndex == 3)
+ if (theBackslashIndex < theLength && theBackslashIndex == 2)
{
// OK, another shot at a file...
theResult = new BinFileInputStream(theSystemID);