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...@apache.org on 2002/04/02 08:12:50 UTC
cvs commit: xml-xalan/c/src/XSLT ElemAttribute.cpp ElemElement.cpp
dbertoni 02/04/01 22:12:50
Modified: c/src/XSLT ElemAttribute.cpp ElemElement.cpp
Log:
Fixed bug with checking for valid name.
Revision Changes Path
1.36 +16 -3 xml-xalan/c/src/XSLT/ElemAttribute.cpp
Index: ElemAttribute.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttribute.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ElemAttribute.cpp 23 Feb 2002 04:23:16 -0000 1.35
+++ ElemAttribute.cpp 2 Apr 2002 06:12:50 -0000 1.36
@@ -174,7 +174,14 @@
m_pNameAVT->evaluate(attrName, sourceNode, *this, executionContext);
- if(!isEmpty(attrName))
+ if(XalanQName::isValidQName(attrName) == false)
+ {
+ executionContext.warn(
+ "The attribute name is invalid",
+ sourceNode,
+ getLocator());
+ }
+ else
{
// save original attribute name
StylesheetExecutionContext::GetAndReleaseCachedString origAttrNameGuard(executionContext);
@@ -353,7 +360,10 @@
if (isEmpty(attrNameSpace))
{
// Could not resolve prefix
- executionContext.warn("Warning: Could not resolve prefix " + nsprefix, sourceNode, this);
+ executionContext.warn(
+ "Warning: Could not resolve prefix",
+ sourceNode,
+ getLocator());
}
else
{
@@ -383,7 +393,10 @@
}
else
{
- executionContext.warn("Warning: Trying to add attribute after element child has been added, ignoring...", sourceNode, this);
+ executionContext.warn(
+ "Attributes cannot be added after a child has been added. The attribute(s) will not be added",
+ sourceNode,
+ getLocator());
}
// If there was no namespace, or the namespace was resolved, process
1.36 +123 -114 xml-xalan/c/src/XSLT/ElemElement.cpp
Index: ElemElement.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemElement.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ElemElement.cpp 23 Feb 2002 04:23:16 -0000 1.35
+++ ElemElement.cpp 2 Apr 2002 06:12:50 -0000 1.36
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -165,171 +165,180 @@
m_nameAVT->evaluate(elemName, sourceNode, *this, executionContext);
- StylesheetExecutionContext::GetAndReleaseCachedString elemNameSpaceGuard(executionContext);
+ bool isIllegalElement = !XalanQName::isValidQName(elemName);
- XalanDOMString& elemNameSpace = elemNameSpaceGuard.get();
-
- if (m_namespaceAVT != 0)
+ if (isIllegalElement == true)
{
- m_namespaceAVT->evaluate(elemNameSpace, sourceNode, *this, executionContext);
- }
+ executionContext.warn(
+ "Illegal element name",
+ sourceNode,
+ getLocator());
- XalanDOMString::size_type namespaceLen = length(elemNameSpace);
+ ElemUse::doExecute(executionContext, false);
- bool isIllegalElement = false;
-
- bool hasUnresolvedPrefix = false;
+ doExecuteChildren(executionContext, true);
+ }
+ else
+ {
+ StylesheetExecutionContext::GetAndReleaseCachedString elemNameSpaceGuard(executionContext);
- bool foundResultNamespaceForPrefix = false;
+ XalanDOMString& elemNameSpace = elemNameSpaceGuard.get();
- XalanDOMString::size_type len = length(elemName);
+ if (m_namespaceAVT != 0)
+ {
+ m_namespaceAVT->evaluate(elemNameSpace, sourceNode, *this, executionContext);
+ }
- const XalanDOMString::size_type indexOfNSSep = indexOf(elemName, XalanUnicode::charColon);
+ XalanDOMString::size_type namespaceLen = length(elemNameSpace);
- const bool haveNamespace = indexOfNSSep == len ? false : true;
+ bool hasUnresolvedPrefix = false;
- StylesheetExecutionContext::GetAndReleaseCachedString prefixGuard(executionContext);
+ bool foundResultNamespaceForPrefix = false;
- XalanDOMString& prefix = prefixGuard.get();
+ XalanDOMString::size_type len = length(elemName);
- if(haveNamespace == true)
- {
- if (indexOfNSSep + 1 == len ||
- isValidNCName(substring(elemName, indexOfNSSep + 1)) == false)
- {
- isIllegalElement = true;
- }
- }
- else if(len == 0 || isValidNCName(elemName) == false)
- {
- isIllegalElement = true;
- }
+ const XalanDOMString::size_type indexOfNSSep = indexOf(elemName, XalanUnicode::charColon);
- if (isIllegalElement == true)
- {
- executionContext.warn("Illegal element name: \"" + elemName + "\"", this, sourceNode);
+ const bool haveNamespace = indexOfNSSep == len ? false : true;
- clear(elemName);
- }
- else if (haveNamespace == true)
- {
- prefix = substring(elemName, 0, indexOfNSSep);
+ StylesheetExecutionContext::GetAndReleaseCachedString prefixGuard(executionContext);
- const XalanDOMString* const theNamespace =
- executionContext.getResultNamespaceForPrefix(prefix);
+ XalanDOMString& prefix = prefixGuard.get();
- if (theNamespace != 0)
- {
- foundResultNamespaceForPrefix = true;
- }
- else
+ if (haveNamespace == true)
{
+ prefix = substring(elemName, 0, indexOfNSSep);
+
const XalanDOMString* const theNamespace =
- m_namespacesHandler.getNamespace(prefix);
+ executionContext.getResultNamespaceForPrefix(prefix);
- if(theNamespace == 0 && namespaceLen == 0)
+ if (theNamespace != 0)
{
- executionContext.warn("Could not resolve prefix: " + prefix, this, sourceNode);
+ foundResultNamespaceForPrefix = true;
+ }
+ else
+ {
+ const XalanDOMString* const theNamespace =
+ m_namespacesHandler.getNamespace(prefix);
- if (m_namespaceAVT != 0)
+ if(theNamespace == 0 && namespaceLen == 0)
{
- hasUnresolvedPrefix = true;
+ executionContext.warn(
+ "Could not resolve prefix",
+ sourceNode,
+ getLocator());
+
+ if (m_namespaceAVT != 0)
+ {
+ hasUnresolvedPrefix = true;
- elemName = substring(elemName, indexOfNSSep + 1);
+ elemName = substring(elemName, indexOfNSSep + 1);
+ }
+ else
+ {
+ isIllegalElement = true;
+
+ executionContext.warn(
+ "Illegal element name",
+ sourceNode,
+ getLocator());
+ }
}
- else
+ else if (theNamespace != 0 &&
+ namespaceLen == 0 &&
+ equals(prefix, DOMServices::s_XMLNamespace) == false)
{
- isIllegalElement = true;
+ elemNameSpace = *theNamespace;
}
}
- else if (theNamespace != 0 &&
- namespaceLen == 0 &&
- equals(prefix, DOMServices::s_XMLNamespace) == false)
- {
- elemNameSpace = *theNamespace;
- }
}
- }
- if (isIllegalElement == false)
- {
- executionContext.startElement(c_wstr(elemName));
-
- if(0 == m_namespaceAVT &&
- (haveNamespace == false || foundResultNamespaceForPrefix == true))
- {
- outputResultNamespaces(executionContext, hasUnresolvedPrefix);
- }
- else
+ if (isIllegalElement == false)
{
- if(namespaceLen == 0 && hasUnresolvedPrefix == true)
+ executionContext.startElement(c_wstr(elemName));
+
+ if(0 == m_namespaceAVT &&
+ (haveNamespace == false || foundResultNamespaceForPrefix == true))
{
- outputResultNamespaces(
- executionContext,
- hasUnresolvedPrefix,
- length(getParentDefaultNamespace()) == 0 ? true : false);
+ outputResultNamespaces(executionContext, hasUnresolvedPrefix);
}
else
{
- if(haveNamespace == false)
+ if(namespaceLen == 0 && hasUnresolvedPrefix == true)
{
- if (namespaceLen > 0)
- {
- outputResultNamespaces(executionContext, hasUnresolvedPrefix);
-
- executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace);
- }
- else
+ outputResultNamespaces(
+ executionContext,
+ hasUnresolvedPrefix,
+ length(getParentDefaultNamespace()) == 0 ? true : false);
+ }
+ else
+ {
+ if(haveNamespace == false)
{
- // OK, the namespace we're generating is the default namespace,
- // so let's make sure that we really need it. If we don't,
- // we end up with another xmlns="" on the element we're
- // generating. Although this isn't really an error, it's
- // a bit unsightly, so let's suppress it...
- const XalanDOMString& theParentDefaultNamespace =
- getParentDefaultNamespace();
-
- if (length(theParentDefaultNamespace) == 0)
+ if (namespaceLen > 0)
{
- // There's not default namespace in effect, so suppress any
- // default namespace in the statically-generated namespaces,
- // and don't put out the one we've dynamically generated...
- outputResultNamespaces(executionContext, hasUnresolvedPrefix, true);
+ outputResultNamespaces(executionContext, hasUnresolvedPrefix);
+
+ executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace);
}
else
{
- outputResultNamespaces(executionContext, hasUnresolvedPrefix, false);
+ // OK, the namespace we're generating is the default namespace,
+ // so let's make sure that we really need it. If we don't,
+ // we end up with another xmlns="" on the element we're
+ // generating. Although this isn't really an error, it's
+ // a bit unsightly, so let's suppress it...
+ const XalanDOMString& theParentDefaultNamespace =
+ getParentDefaultNamespace();
+
+ if (length(theParentDefaultNamespace) == 0)
+ {
+ // There's not default namespace in effect, so suppress any
+ // default namespace in the statically-generated namespaces,
+ // and don't put out the one we've dynamically generated...
+ outputResultNamespaces(executionContext, hasUnresolvedPrefix, true);
+ }
+ else
+ {
+ outputResultNamespaces(executionContext, hasUnresolvedPrefix, false);
- executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace);
+ executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace);
+ }
}
}
- }
- else
- {
- outputResultNamespaces(executionContext, hasUnresolvedPrefix);
+ else
+ {
+ outputResultNamespaces(executionContext, hasUnresolvedPrefix);
- const XalanDOMString* const theNamespace =
- executionContext.getResultNamespaceForPrefix(prefix);
+ const XalanDOMString* const theNamespace =
+ executionContext.getResultNamespaceForPrefix(prefix);
- if (theNamespace == 0 ||
- equals(*theNamespace, elemNameSpace) == false)
- {
- insert(prefix, 0, DOMServices::s_XMLNamespaceWithSeparator);
+ if (theNamespace == 0 ||
+ equals(*theNamespace, elemNameSpace) == false)
+ {
+ insert(prefix, 0, DOMServices::s_XMLNamespaceWithSeparator);
- executionContext.addResultAttribute(prefix, elemNameSpace);
+ executionContext.addResultAttribute(prefix, elemNameSpace);
+ }
}
}
}
}
- }
- ElemUse::execute(executionContext);
+ if (isIllegalElement == true)
+ {
+ ElemUse::doExecute(executionContext, false);
+
+ doExecuteChildren(executionContext, true);
+ }
+ else
+ {
+ ElemUse::doExecute(executionContext, true);
- doExecuteChildren(executionContext, isIllegalElement);
+ doExecuteChildren(executionContext, false);
- if (isIllegalElement == false)
- {
- executionContext.endElement(c_wstr(elemName));
+ executionContext.endElement(c_wstr(elemName));
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org