Merge more train-work, mainly around xsl:keyt and key() implementation

This commit is contained in:
jez 2009-03-04 12:43:45 +00:00
commit 4eeda060a6
5 changed files with 96 additions and 56 deletions

View file

@ -3,6 +3,7 @@
#include "../xslt_inline_element.hpp"
#include "xslt_item_container_handler.hpp"
#include "xslt_constants.hpp"
namespace Arabica
{
@ -28,19 +29,21 @@ protected:
{
if(atts.getQName(i).find("xmlns:") == 0)
continue;
if(atts.getURI(i) == StylesheetConstant::NamespaceURI())
continue;
if(!context().isRemapped(atts.getURI(i)))
inlineAtts.push_back(InlineAttribute(atts.getQName(i),
atts.getURI(i),
context().xpath_attribute_value_template(atts.getValue(i))));
atts.getURI(i),
context().xpath_attribute_value_template(atts.getValue(i))));
else
{
std::pair<std::string, std::string> remap = context().remappedNamespace(atts.getURI(i));
if(remap.first.empty() && !remap.second.empty())
remap.first = context().autoNamespacePrefix();
std::string name = remap.first + ":" + atts.getLocalName(i);
inlineAtts.push_back(InlineAttribute(name,
remap.second,
context().xpath_attribute_value_template(atts.getValue(i))));
remap.first = context().autoNamespacePrefix();
std::string name = remap.first + ":" + atts.getLocalName(i);
inlineAtts.push_back(InlineAttribute(name,
remap.second,
context().xpath_attribute_value_template(atts.getValue(i))));
} // if ...
} // for ...

View file

@ -79,17 +79,30 @@ public:
virtual Arabica::XPath::XPathValue_impl<std::string>* evaluate(const DOM::Node<std::string>& context,
const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
{
std::string keyname = argAsString(0, context, executionContext);
std::string keyClarkName = XML::QualifiedName<std::string>::parseQName(keyname, true, UriMapper(namespaces_)).clarkName();
Arabica::XPath::XPathValue<std::string> a1 = baseT::arg(1, context, executionContext);
if(a1.type() == Arabica::XPath::NODE_SET)
throw Arabica::XPath::UnsupportedException("node-set arg version of key()");
return nodeSetUnion(keyClarkName, a1.asNodeSet(), executionContext);
std::string keyname = argAsString(0, context, executionContext);
std::string id = a1.asString();
std::string clarkName = XML::QualifiedName<std::string>::parseQName(keyname, true, UriMapper(namespaces_)).clarkName();
return new Arabica::XPath::NodeSetValue<std::string>(keys_.lookup(clarkName, id, executionContext));
return new Arabica::XPath::NodeSetValue<std::string>(keys_.lookup(keyClarkName, a1.asString(), executionContext));
} // evaluate
Arabica::XPath::XPathValue_impl<std::string>* nodeSetUnion(const std::string& keyClarkName,
const Arabica::XPath::NodeSet<std::string> nodes,
const Arabica::XPath::ExecutionContext<std::string>& executionContext) const
{
Arabica::XPath::NodeSet<std::string> results;
for(Arabica::XPath::NodeSet<std::string>::const_iterator n = nodes.begin(), ne = nodes.end(); n != ne; ++n)
{
std::string id = Arabica::XPath::impl::nodeStringValue<std::string, Arabica::default_string_adaptor<std::string> >(*n);
results.push_back(keys_.lookup(keyClarkName, id, executionContext));
} // for ...
results.to_document_order();
return new Arabica::XPath::NodeSetValue<std::string>(results);
} // nodeSetUnion
private:
const DeclaredKeys& keys_;
std::map<std::string, std::string> namespaces_;

View file

@ -53,8 +53,12 @@ private:
for(MatchExprList::const_iterator me = matches_.begin(), mee = matches_.end(); me != mee; ++me)
if(me->evaluate(node, context))
{
std::string id = use_.evaluateAsString(node, context);
nodes[id].push_back(node);
Arabica::XPath::NodeSet<std::string> ids = use_.evaluateAsNodeSet(node, context);
for(Arabica::XPath::NodeSet<std::string>::const_iterator i = ids.begin(), ie = ids.end(); i != ie; ++i)
{
std::string id = Arabica::XPath::impl::nodeStringValue<std::string, Arabica::default_string_adaptor<std::string> >(*i);
nodes[id].push_back(node);
} // for ...
break;
} // if ...
} // for
@ -96,7 +100,7 @@ public:
Arabica::XPath::NodeSet<std::string> nodes;
for(KeyList::const_iterator key = k->second.begin(), keye = k->second.end(); key != keye; ++key)
nodes.push_back((*key)->lookup(id, context));
nodes.sort();
nodes.to_document_order();
return nodes;
} // lookup

View file

@ -403,7 +403,7 @@ class URITest : public TestCase
assertEquals("woot.txt", u.path());
assertEquals(false, u.is_absolute());
assertEquals("file:woot.txt", u.as_string());
} // URI
} // test35
void test36()
{
@ -461,7 +461,30 @@ class URITest : public TestCase
assertEquals(true, u.is_absolute());
assertEquals("http://www.google.com", u.as_string());
} // test40
}; // class URITest
void test41()
{
URI u("file:fragtastic/woot.txt");
assertEquals("", u.host());
assertEquals("file", u.scheme());
assertEquals("fragtastic/woot.txt", u.path());
assertEquals(false, u.is_absolute());
assertEquals("file:fragtastic/woot.txt", u.as_string());
} // test41
void test42()
{
URI b("wooo/main.txt");
URI u(b, "file:fragtastic/woot.txt");
assertEquals("", u.host());
assertEquals("file", u.scheme());
assertEquals("wooo/fragtastic/woot.txt", u.path());
assertEquals(false, u.is_absolute());
assertEquals("file:wooo/fragtastic/woot.txt", u.as_string());
} // test42
}; // class URITest
TestSuite* URITest_suite()
{
@ -506,7 +529,9 @@ TestSuite* URITest_suite()
suiteOfTests->addTest(new TestCaller<URITest>("test37", &URITest::test37));
suiteOfTests->addTest(new TestCaller<URITest>("test38", &URITest::test38));
suiteOfTests->addTest(new TestCaller<URITest>("test39", &URITest::test39));
suiteOfTests->addTest(new TestCaller<URITest>("test40", &URITest::test40));
suiteOfTests->addTest(new TestCaller<URITest>("test40", &URITest::test40));
suiteOfTests->addTest(new TestCaller<URITest>("test41", &URITest::test41));
suiteOfTests->addTest(new TestCaller<URITest>("test42", &URITest::test42));
return suiteOfTests;
} // URITest_suite

View file

@ -16,12 +16,11 @@
<test-case id="expression_expression04" compiles="no" reason="Needs lang"/>
<test-case id="expression_expression05" compiles="no" reason="Needs lang"/>
<test-case id="expression_expression06" compiles="no" reason="Needs lang"/>
<test-case id="extend_extend01" compiles="no"/>
<test-case id="extend_extend02" compiles="no"/>
<test-case id="extend_extend03" compiles="no"/>
<test-case id="extend_extend04" compiles="no"/>
<test-case id="impincl_impincl09" compiles="no"/>
<test-case id="impincl_impincl17" compiles="no"/>
<test-case id="extend_extend01" compiles="no" reason="Needs fallback, extension elements"/>
<test-case id="extend_extend02" compiles="no" reason="Needs fallback, extension elements"/>
<test-case id="extend_extend03" compiles="no" reason="Needs function-available, element-available"/>
<test-case id="extend_extend04" compiles="no" reason="Needs fallback, extension elements"/>
<test-case id="impincl_impincl09" compiles="no" reasons="Needs attribute sets"/>
<test-case id="lre_lre12" compiles="no" reason="Failing to compile is actually legitimate here. Saxon and MSXML agree, Xalan chooses to continue."/>
<test-case id="lre_lre13" compare="text" reason="Text out"/>
<test-case id="match_match01" compiles="no" reason="Needs xsl:strip-space"/>
@ -34,9 +33,9 @@
<test-case id="mdocs_mdocs08" runs="no" reason="haven't implemented node-set arg version of document()"/>
<test-case id="mdocs_mdocs18" runs="no" reason="haven't implemented node-set arg version of document()"/>
<test-case id="message_message01" compare="text"/>
<test-case id="message_message14" compiles="no"/>
<test-case id="message_message15" compiles="no"/>
<test-case id="namedtemplate_namedtemplate12" compiles="no"/>
<test-case id="message_message14" compiles="no" reason="Needs xsl:number"/>
<test-case id="message_message15" compiles="no" reason="Needs xsl:fallback"/>
<test-case id="namedtemplate_namedtemplate12" compiles="no" reason="Needs xsl:number"/>
<test-case id="output_output01" skip="yes" reason="HTML output"/>
<test-case id="output_output02" skip="yes" reason="HTML output"/>
<test-case id="output_output03" skip="yes" reason="HTML output"/>
@ -98,10 +97,6 @@
<test-case id="reluri_reluri10" runs="no"/>
<test-case id="reluri_reluri11" runs="no"/>
<test-case id="select_select07" compare="text" reason="Text output"/>
<test-case id="select_select54" compiles="no"/>
<test-case id="select_select55" compiles="no"/>
<test-case id="select_select59" compiles="no"/>
<test-case id="select_select64" compiles="no"/>
<test-case id="select_select74" skip="yes" reason="HTML output"/>
<test-case id="sort_sort08" skip="yes" reason="Test case is bad. Xalan sorts % ahead of space. Others, including comment in test data, disagree."/>
<test-case id="sort_sort14" compiles="no" reason="Needs xsl:sort lang attribute"/>
@ -122,30 +117,30 @@
<test-case id="sort_sort37" compare="text" reason="Text output"/>
<test-case id="sort_sort39" compiles="no" reason="Needs xsl:sort lang attribute"/>
<test-case id="string_string13" compiles="no"/>
<test-case id="string_string106" compiles="no"/>
<test-case id="string_string108" compiles="no"/>
<test-case id="string_string109" compiles="no"/>
<test-case id="string_string110" compiles="no"/>
<test-case id="string_string124" compiles="no"/>
<test-case id="string_string129" compiles="no"/>
<test-case id="string_string130" compiles="no"/>
<test-case id="variable_variable20" runs="no" reason="Possible spec ambiguity. Mangle agrees with Saxon and MSXML. Xalan disagrees"/>
<test-case id="variable_variable56" runs="no" reason="Possible spec ambiguity. Mangle agrees with Saxon and MSXML. Xalan disagrees"/>
<test-case id="ver_ver01" compiles="no"/>
<test-case id="ver_ver05" compiles="no"/>
<test-case id="ver_ver06" compiles="no"/>
<test-case id="ver_ver07" compiles="no"/>
<test-case id="whitespace_whitespace01" compiles="no"/>
<test-case id="whitespace_whitespace02" compiles="no"/>
<test-case id="whitespace_whitespace03" compiles="no"/>
<test-case id="whitespace_whitespace04" compiles="no"/>
<test-case id="whitespace_whitespace05" compiles="no"/>
<test-case id="whitespace_whitespace06" compiles="no"/>
<test-case id="whitespace_whitespace07" compiles="no"/>
<test-case id="whitespace_whitespace12" compiles="no"/>
<test-case id="whitespace_whitespace22" compiles="no"/>
<test-case id="whitespace_whitespace35" compiles="no"/>
<test-case id="string_string13" compiles="no" reason="Needs format-number"/>
<test-case id="string_string106" compiles="no" reason="Needs format-number"/>
<test-case id="string_string108" compiles="no" reason="Needs format-number"/>
<test-case id="string_string109" compiles="no" reason="Needs format-number"/>
<test-case id="string_string110" compiles="no" reason="Needs format-number"/>
<test-case id="string_string124" compiles="no" reason="Needs strip-space"/>
<test-case id="string_string129" compiles="no" reason="Needs strip-space"/>
<test-case id="string_string130" compiles="no" reason="Needs strip-space"/>
<test-case id="variable_variable20" runs="no" reason="Possible spec ambiguity. Mangle agrees with Saxon and MSXML. Xalan disagrees"/>
<test-case id="variable_variable56" runs="no" reason="Possible spec ambiguity. Mangle agrees with Saxon and MSXML. Xalan disagrees"/>
<test-case id="ver_ver01" compiles="no" reason="Forward compatibility"/>
<test-case id="ver_ver05" compiles="no" reason="Forward compatibility"/>
<test-case id="ver_ver06" compiles="no" reason="Forward compatibility"/>
<test-case id="ver_ver07" compiles="no" reason="Forward compatibility"/>
<test-case id="whitespace_whitespace01" compiles="no" reason="Needs xsl:strip-space"/>
<test-case id="whitespace_whitespace02" compiles="no" reason="Needs xsl:strip-space"/>
<test-case id="whitespace_whitespace03" compiles="no" reason="Needs xsl:strip-space"/>
<test-case id="whitespace_whitespace04" compiles="no" reason="Needs xsl:strip-space and xsl:preserve-space"/>
<test-case id="whitespace_whitespace05" compiles="no" reason="Needs xsl:strip-space"/>
<test-case id="whitespace_whitespace06" compiles="no" reason="Needs xsl:strip-space"/>
<test-case id="whitespace_whitespace07" compiles="no" reason="Needs xsl:strip-space"/>
<test-case id="whitespace_whitespace12" compiles="no" reason="Needs xsl:strip-space"/>
<test-case id="whitespace_whitespace22" compiles="no" reason="Needs xsl:strip-space and xsl:preserve-space"/>
<test-case id="whitespace_whitespace35" compiles="no" reason="Needs xsl:strip-space"//>
<test-case id="AVTs__77531" compare="fragment" reason="XML Fragment output"/>
<test-case id="AVTs__77558" compare="fragment" reason="XML Fragment output"/>