|
|
@@ -14,21 +14,38 @@ using System.Xml;
|
|
|
using System.Xml.Schema;
|
|
|
using System.Xml.XPath;
|
|
|
using System.Xml.Xsl;
|
|
|
+using Mono.Xml.Xsl;
|
|
|
+using Mono.Xml.Xsl.Functions;
|
|
|
|
|
|
namespace Mono.Xml.XPath {
|
|
|
- internal class KeyPattern : Pattern {
|
|
|
+ internal class KeyPattern : LocationPathPattern {
|
|
|
|
|
|
+ XmlQualifiedName keyName;
|
|
|
string arg0, arg1;
|
|
|
+ XsltKey key;
|
|
|
|
|
|
- public KeyPattern (string arg0, string arg1)
|
|
|
+ public KeyPattern (XsltKey key)
|
|
|
+ : base ((NodeTest) null)
|
|
|
{
|
|
|
- this.arg0 = arg0;
|
|
|
- this.arg1 = arg1;
|
|
|
+ this.key = key;
|
|
|
+ ExprLiteral keyName = key.KeyName as ExprLiteral;
|
|
|
+ ExprLiteral field = key.Field as ExprLiteral;
|
|
|
+ this.arg0 = keyName.Value;
|
|
|
+ this.arg1 = field.Value;
|
|
|
+ this.keyName = XslNameUtil.FromString (arg0, key.NamespaceManager);
|
|
|
}
|
|
|
|
|
|
public override bool Matches (XPathNavigator node, XsltContext ctx)
|
|
|
{
|
|
|
- throw new NotImplementedException ();
|
|
|
+ XsltCompiledContext xctx = ctx as XsltCompiledContext;
|
|
|
+ XslKey xslkey = xctx.Processor.CompiledStyle.Keys [keyName] as XslKey;
|
|
|
+ XPathNodeIterator iter = key.EvaluateNodeSet (new SelfIterator (node, ctx));
|
|
|
+ if (iter.MoveNext ())
|
|
|
+ return iter.Current.IsSamePosition (node);
|
|
|
+ else
|
|
|
+ return false;
|
|
|
}
|
|
|
+
|
|
|
+ public override double DefaultPriority { get { return 0.5; } }
|
|
|
}
|
|
|
}
|