83a706133623d458c8c201373b415b8367f25fcc
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / SchemaContextUtil.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.util;
9
10 import com.google.common.base.Function;
11 import com.google.common.base.Preconditions;
12 import com.google.common.base.Splitter;
13 import com.google.common.collect.Iterables;
14 import java.util.Iterator;
15 import java.util.LinkedList;
16 import java.util.List;
17 import java.util.Set;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
20 import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
21 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
24 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
25 import org.opendaylight.yangtools.yang.model.api.Module;
26 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
27 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
28 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
29 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
30 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
31 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
32 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
35
36 /**
37  * The Schema Context Util contains support methods for searching through Schema
38  * Context modules for specified schema nodes via Schema Path or Revision Aware
39  * XPath. The Schema Context Util is designed as mixin, so it is not
40  * instantiable.
41  *
42  */
43 public final class SchemaContextUtil {
44     private static final Logger LOG = LoggerFactory.getLogger(SchemaContextUtil.class);
45     private static final Splitter COLON_SPLITTER = Splitter.on(':');
46     private static final Splitter SLASH_SPLITTER = Splitter.on('/');
47
48     private SchemaContextUtil() {
49     }
50
51     /**
52      * Method attempts to find DataSchemaNode in Schema Context via specified
53      * Schema Path. The returned DataSchemaNode from method will be the node at
54      * the end of the SchemaPath. If the DataSchemaNode is not present in the
55      * Schema Context the method will return <code>null</code>. <br>
56      * In case that Schema Context or Schema Path are not specified correctly
57      * (i.e. contains <code>null</code> values) the method will return
58      * IllegalArgumentException.
59      *
60      * @throws IllegalArgumentException
61      *
62      * @param context
63      *            Schema Context
64      * @param schemaPath
65      *            Schema Path to search for
66      * @return SchemaNode from the end of the Schema Path or <code>null</code>
67      *         if the Node is not present.
68      */
69     public static SchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
70         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
71         Preconditions.checkArgument(schemaPath != null, "Schema Path reference cannot be NULL");
72
73         final Iterable<QName> prefixedPath = schemaPath.getPathFromRoot();
74         if (prefixedPath == null) {
75             LOG.debug("Schema path {} has null path", schemaPath);
76             return null;
77         }
78
79         LOG.trace("Looking for path {} in context {}", schemaPath, context);
80         return findNodeInSchemaContext(context, prefixedPath);
81     }
82
83     /**
84      * Method attempts to find DataSchemaNode inside of provided Schema Context
85      * and Yang Module accordingly to Non-conditional Revision Aware XPath. The
86      * specified Module MUST be present in Schema Context otherwise the
87      * operation would fail and return <code>null</code>. <br>
88      * The Revision Aware XPath MUST be specified WITHOUT the conditional
89      * statement (i.e. without [cond]) in path, because in this state the Schema
90      * Context is completely unaware of data state and will be not able to
91      * properly resolve XPath. If the XPath contains condition the method will
92      * return IllegalArgumentException. <br>
93      * In case that Schema Context or Module or Revision Aware XPath contains
94      * <code>null</code> references the method will throw
95      * IllegalArgumentException <br>
96      * If the Revision Aware XPath is correct and desired Data Schema Node is
97      * present in Yang module or in depending module in Schema Context the
98      * method will return specified Data Schema Node, otherwise the operation
99      * will fail and method will return <code>null</code>.
100      *
101      * @throws IllegalArgumentException
102      *
103      * @param context
104      *            Schema Context
105      * @param module
106      *            Yang Module
107      * @param nonCondXPath
108      *            Non Conditional Revision Aware XPath
109      * @return Returns Data Schema Node for specified Schema Context for given
110      *         Non-conditional Revision Aware XPath, or <code>null</code> if the
111      *         DataSchemaNode is not present in Schema Context.
112      */
113     public static SchemaNode findDataSchemaNode(final SchemaContext context, final Module module, final RevisionAwareXPath nonCondXPath) {
114         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
115         Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
116         Preconditions.checkArgument(nonCondXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
117
118         String strXPath = nonCondXPath.toString();
119         if (strXPath != null) {
120             Preconditions.checkArgument(strXPath.indexOf('[') == -1, "Revision Aware XPath may not contain a condition");
121             if (nonCondXPath.isAbsolute()) {
122                 List<QName> qnamedPath = xpathToQNamePath(context, module, strXPath);
123                 if (qnamedPath != null) {
124                     return findNodeInSchemaContext(context, qnamedPath);
125                 }
126             }
127         }
128         return null;
129     }
130
131     /**
132      * Method attempts to find DataSchemaNode inside of provided Schema Context
133      * and Yang Module accordingly to Non-conditional relative Revision Aware
134      * XPath. The specified Module MUST be present in Schema Context otherwise
135      * the operation would fail and return <code>null</code>. <br>
136      * The relative Revision Aware XPath MUST be specified WITHOUT the
137      * conditional statement (i.e. without [cond]) in path, because in this
138      * state the Schema Context is completely unaware of data state and will be
139      * not able to properly resolve XPath. If the XPath contains condition the
140      * method will return IllegalArgumentException. <br>
141      * The Actual Schema Node MUST be specified correctly because from this
142      * Schema Node will search starts. If the Actual Schema Node is not correct
143      * the operation will simply fail, because it will be unable to find desired
144      * DataSchemaNode. <br>
145      * In case that Schema Context or Module or Actual Schema Node or relative
146      * Revision Aware XPath contains <code>null</code> references the method
147      * will throw IllegalArgumentException <br>
148      * If the Revision Aware XPath doesn't have flag
149      * <code>isAbsolute == false</code> the method will throw
150      * IllegalArgumentException. <br>
151      * If the relative Revision Aware XPath is correct and desired Data Schema
152      * Node is present in Yang module or in depending module in Schema Context
153      * the method will return specified Data Schema Node, otherwise the
154      * operation will fail and method will return <code>null</code>.
155      *
156      * @throws IllegalArgumentException
157      *
158      * @param context
159      *            Schema Context
160      * @param module
161      *            Yang Module
162      * @param actualSchemaNode
163      *            Actual Schema Node
164      * @param relativeXPath
165      *            Relative Non Conditional Revision Aware XPath
166      * @return DataSchemaNode if is present in specified Schema Context for
167      *         given relative Revision Aware XPath, otherwise will return
168      *         <code>null</code>.
169      */
170     public static SchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, final Module module,
171             final SchemaNode actualSchemaNode, final RevisionAwareXPath relativeXPath) {
172         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
173         Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
174         Preconditions.checkArgument(actualSchemaNode != null, "Actual Schema Node reference cannot be NULL");
175         Preconditions.checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
176         Preconditions.checkState(!relativeXPath.isAbsolute(),
177                 "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
178                         + "for non relative Revision Aware XPath use findDataSchemaNode method");
179
180         SchemaPath actualNodePath = actualSchemaNode.getPath();
181         if (actualNodePath != null) {
182             Iterable<QName> qnamePath = resolveRelativeXPath(context, module, relativeXPath, actualSchemaNode);
183
184             if (qnamePath != null) {
185                 return findNodeInSchemaContext(context, qnamePath);
186             }
187         }
188         return null;
189     }
190
191     /**
192      * Returns parent Yang Module for specified Schema Context in which Schema
193      * Node is declared. If the Schema Node is not present in Schema Context the
194      * operation will return <code>null</code>. <br>
195      * If Schema Context or Schema Node contains <code>null</code> references
196      * the method will throw IllegalArgumentException
197      *
198      * @throws IllegalArgumentException
199      *
200      * @param context
201      *            Schema Context
202      * @param schemaNode
203      *            Schema Node
204      * @return Yang Module for specified Schema Context and Schema Node, if
205      *         Schema Node is NOT present, the method will returns
206      *         <code>null</code>
207      */
208     public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
209         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL!");
210         Preconditions.checkArgument(schemaNode != null, "Schema Node cannot be NULL!");
211         Preconditions.checkState(schemaNode.getPath() != null, "Schema Path for Schema Node is not "
212                 + "set properly (Schema Path is NULL)");
213
214         final QName qname = Iterables.getFirst(schemaNode.getPath().getPathTowardsRoot(), null);
215         Preconditions.checkState(qname != null,
216                 "Schema Path contains invalid state of path parts. " +
217                 "The Schema Path MUST contain at least ONE QName which defines namespace and Local name of path.");
218         return context.findModuleByNamespaceAndRevision(qname.getNamespace(), qname.getRevision());
219     }
220
221     public static SchemaNode findNodeInSchemaContext(final SchemaContext context, final Iterable<QName> path) {
222         final QName current = path.iterator().next();
223
224         LOG.trace("Looking up module {} in context {}", current, path);
225         final Module module = context.findModuleByNamespaceAndRevision(current.getNamespace(), current.getRevision());
226         if (module == null) {
227             LOG.debug("Module {} not found", current);
228             return null;
229         }
230
231         return findNodeInModule(module, path);
232     }
233
234     private static SchemaNode findNodeInModule(final Module module, final Iterable<QName> path) {
235         final QName current = path.iterator().next();
236
237         LOG.trace("Looking for data container {} in module {}", current, module);
238         SchemaNode parent = module.getDataChildByName(current);
239         if (parent != null) {
240             final SchemaNode ret = findNode((DataSchemaNode) parent, nextLevel(path));
241             if (ret != null) {
242                 return ret;
243             }
244         }
245
246         LOG.trace("Looking for RPC {} in module {}", current, module);
247         parent = getRpcByName(module, current);
248         if (parent != null) {
249             final SchemaNode ret = findNodeInRpc((RpcDefinition) parent, nextLevel(path));
250             if (ret != null) {
251                 return ret;
252             }
253         }
254
255         LOG.trace("Looking for notification {} in module {}", current, module);
256         parent = getNotificationByName(module, current);
257         if (parent != null) {
258             final SchemaNode ret = findNodeInNotification((NotificationDefinition) parent, nextLevel(path));
259             if (ret != null) {
260                 return ret;
261             }
262         }
263
264         LOG.trace("Looking for grouping {} in module {}", current, module);
265         parent = getGroupingByName(module, current);
266         if (parent != null) {
267             final SchemaNode ret = findNodeInGrouping((GroupingDefinition) parent, nextLevel(path));
268             if (ret != null) {
269                 return ret;
270             }
271         }
272
273         LOG.debug("No node matching {} found in module {}", path, module);
274         return null;
275     }
276
277     private static SchemaNode findNodeInGrouping(
278             final GroupingDefinition grouping, final Iterable<QName> path) {
279         final QName current = Iterables.getFirst(path, null);
280         if (current == null) {
281             LOG.debug("Found grouping {}", grouping);
282             return grouping;
283         }
284
285         LOG.trace("Looking for path {} in grouping {}", path, grouping);
286         final DataSchemaNode node = grouping.getDataChildByName(current);
287
288         if (node != null)
289             return findNode(node, nextLevel(path));
290
291         for (GroupingDefinition groupingDefinition : grouping.getGroupings()) {
292             if (groupingDefinition.getQName().equals(current))
293                 return findNodeInGrouping(groupingDefinition, nextLevel(path));
294         }
295
296         LOG.debug("No node matching {} found in grouping {}", current, grouping);
297         return null;
298     }
299
300     private static SchemaNode findNodeInRpc(final RpcDefinition rpc, final Iterable<QName> path) {
301         final QName current = Iterables.getFirst(path, null);
302         if (current == null) {
303             LOG.debug("Found RPC {}", rpc);
304             return rpc;
305         }
306
307         LOG.trace("Looking for path {} in rpc {}", path, rpc);
308         switch (current.getLocalName()) {
309         case "input":
310             return findNode(rpc.getInput(), nextLevel(path));
311         case "output":
312             return findNode(rpc.getOutput(), nextLevel(path));
313         default:
314             LOG.debug("Invalid component {} of path {} in RPC {}", current, path, rpc);
315             return null;
316         }
317     }
318
319     private static SchemaNode findNodeInNotification(final NotificationDefinition ntf, final Iterable<QName> path) {
320         final QName current = Iterables.getFirst(path, null);
321         if (current == null) {
322             LOG.debug("Found notification {}", ntf);
323             return ntf;
324         }
325
326         LOG.trace("Looking for path {} in notification {}", path, ntf);
327         DataSchemaNode node = ntf.getDataChildByName(current);
328         if (node == null) {
329             LOG.debug("No node matching {} found in notification {}", current, ntf);
330             return null;
331         }
332
333         return findNode(node, nextLevel(path));
334     }
335
336     private static SchemaNode findNode(final ChoiceNode parent, final Iterable<QName> path) {
337         final QName current = Iterables.getFirst(path, null);
338         if (current == null) {
339             return parent;
340         }
341         ChoiceCaseNode node = parent.getCaseNodeByName(current);
342         if (node != null) {
343             return findNodeInCase(node, nextLevel(path));
344         }
345         return null;
346     }
347
348     private static SchemaNode findNode(final ContainerSchemaNode parent, final Iterable<QName> path) {
349         final QName current = Iterables.getFirst(path, null);
350         if (current == null) {
351             return parent;
352         }
353
354         final DataSchemaNode node = parent.getDataChildByName(current);
355         if (node == null) {
356             LOG.debug("Failed to find {} in parent {}", path, parent);
357             return null;
358         }
359
360         return findNode(node, nextLevel(path));
361     }
362
363     private static SchemaNode findNode(final ListSchemaNode parent, final Iterable<QName> path) {
364         final QName current = Iterables.getFirst(path, null);
365         if (current == null) {
366             return parent;
367         }
368
369         DataSchemaNode node = parent.getDataChildByName(current);
370         if (node == null) {
371             LOG.debug("Failed to find {} in parent {}", path, parent);
372             return null;
373         }
374         return findNode(node, nextLevel(path));
375     }
376
377     private static SchemaNode findNode(final DataSchemaNode parent, final Iterable<QName> path) {
378         final SchemaNode node;
379         if (!Iterables.isEmpty(path)) {
380             if (parent instanceof ContainerSchemaNode) {
381                 node = findNode((ContainerSchemaNode) parent, path);
382             } else if (parent instanceof ListSchemaNode) {
383                 node = findNode((ListSchemaNode) parent, path);
384             } else if (parent instanceof ChoiceNode) {
385                 node = findNode((ChoiceNode) parent, path);
386             } else {
387                 throw new IllegalArgumentException(
388                         String.format("Path nesting violation in parent %s path %s", parent, path));
389             }
390         } else {
391             node = parent;
392         }
393
394         if (node == null) {
395             LOG.debug("Failed to find {} in parent {}", path, parent);
396             return null;
397         }
398         return node;
399     }
400
401     private static SchemaNode findNodeInCase(final ChoiceCaseNode parent, final Iterable<QName> path) {
402         final QName current = Iterables.getFirst(path, null);
403         if (current == null) {
404             return parent;
405         }
406
407         DataSchemaNode node = parent.getDataChildByName(current);
408         if (node == null) {
409             LOG.debug("Failed to find {} in parent {}", path, parent);
410             return null;
411         }
412         return findNode(node, nextLevel(path));
413     }
414
415     private static RpcDefinition getRpcByName(final Module module, final QName name) {
416         for (RpcDefinition rpc : module.getRpcs()) {
417             if (rpc.getQName().equals(name)) {
418                 return rpc;
419             }
420         }
421         return null;
422     }
423
424     private static Iterable<QName> nextLevel(final Iterable<QName> path) {
425         return Iterables.skip(path, 1);
426     }
427
428     private static NotificationDefinition getNotificationByName(final Module module, final QName name) {
429         for (NotificationDefinition notification : module.getNotifications()) {
430             if (notification.getQName().equals(name)) {
431                 return notification;
432             }
433         }
434         return null;
435     }
436
437     private static GroupingDefinition getGroupingByName(final Module module, final QName name) {
438         for (GroupingDefinition grouping : module.getGroupings()) {
439             if (grouping.getQName().equals(name)) {
440                 return grouping;
441             }
442         }
443         return null;
444     }
445
446     /**
447      * Transforms string representation of XPath to Queue of QNames. The XPath
448      * is split by "/" and for each part of XPath is assigned correct module in
449      * Schema Path. <br>
450      * If Schema Context, Parent Module or XPath string contains
451      * <code>null</code> values, the method will throws IllegalArgumentException
452      *
453      * @throws IllegalArgumentException
454      *
455      * @param context
456      *            Schema Context
457      * @param parentModule
458      *            Parent Module
459      * @param xpath
460      *            XPath String
461      * @return return a list of QName
462      */
463     private static List<QName> xpathToQNamePath(final SchemaContext context, final Module parentModule, final String xpath) {
464         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
465         Preconditions.checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
466         Preconditions.checkArgument(xpath != null, "XPath string reference cannot be NULL");
467
468         List<QName> path = new LinkedList<QName>();
469         for (String pathComponent : SLASH_SPLITTER.split(xpath)) {
470             if (!pathComponent.isEmpty()) {
471                 path.add(stringPathPartToQName(context, parentModule, pathComponent));
472             }
473         }
474         return path;
475     }
476
477     /**
478      * Transforms part of Prefixed Path as java String to QName. <br>
479      * If the string contains module prefix separated by ":" (i.e.
480      * mod:container) this module is provided from from Parent Module list of
481      * imports. If the Prefixed module is present in Schema Context the QName
482      * can be constructed. <br>
483      * If the Prefixed Path Part does not contains prefix the Parent's Module
484      * namespace is taken for construction of QName. <br>
485      * If Schema Context, Parent Module or Prefixed Path Part refers to
486      * <code>null</code> the method will throw IllegalArgumentException
487      *
488      * @throws IllegalArgumentException
489      *
490      * @param context
491      *            Schema Context
492      * @param parentModule
493      *            Parent Module
494      * @param prefixedPathPart
495      *            Prefixed Path Part string
496      * @return QName from prefixed Path Part String.
497      */
498     private static QName stringPathPartToQName(final SchemaContext context, final Module parentModule, final String prefixedPathPart) {
499         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
500         Preconditions.checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
501         Preconditions.checkArgument(prefixedPathPart != null, "Prefixed Path Part cannot be NULL!");
502
503         if (prefixedPathPart.indexOf(':') != -1) {
504             final Iterator<String> prefixedName = COLON_SPLITTER.split(prefixedPathPart).iterator();
505             final String modulePrefix = prefixedName.next();
506
507             Module module = resolveModuleForPrefix(context, parentModule, modulePrefix);
508             Preconditions.checkArgument(module != null, "Failed to resolve xpath: no module found for prefix %s in module %s",
509                     modulePrefix, parentModule.getName());
510
511             // FIXME: Module should have a QNameModule handle
512             return QName.create(module.getNamespace(), module.getRevision(), prefixedName.next());
513         } else {
514             return QName.create(parentModule.getNamespace(), parentModule.getRevision(), prefixedPathPart);
515         }
516     }
517
518     /**
519      * Method will attempt to resolve and provide Module reference for specified
520      * module prefix. Each Yang module could contains multiple imports which
521      * MUST be associated with corresponding module prefix. The method simply
522      * looks into module imports and returns the module that is bounded with
523      * specified prefix. If the prefix is not present in module or the prefixed
524      * module is not present in specified Schema Context, the method will return
525      * <code>null</code>. <br>
526      * If String prefix is the same as prefix of the specified Module the
527      * reference to this module is returned. <br>
528      * If Schema Context, Module or Prefix are referring to <code>null</code>
529      * the method will return IllegalArgumentException
530      *
531      * @throws IllegalArgumentException
532      *
533      * @param context
534      *            Schema Context
535      * @param module
536      *            Yang Module
537      * @param prefix
538      *            Module Prefix
539      * @return Module for given prefix in specified Schema Context if is
540      *         present, otherwise returns <code>null</code>
541      */
542     private static Module resolveModuleForPrefix(final SchemaContext context, final Module module, final String prefix) {
543         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
544         Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
545         Preconditions.checkArgument(prefix != null, "Prefix string cannot be NULL");
546
547         if (prefix.equals(module.getPrefix())) {
548             return module;
549         }
550
551         Set<ModuleImport> imports = module.getImports();
552         for (ModuleImport mi : imports) {
553             if (prefix.equals(mi.getPrefix())) {
554                 return context.findModuleByName(mi.getModuleName(), mi.getRevision());
555             }
556         }
557         return null;
558     }
559
560     /**
561      * @throws IllegalArgumentException
562      *
563      * @param context
564      *            Schema Context
565      * @param module
566      *            Yang Module
567      * @param relativeXPath
568      *            Non conditional Revision Aware Relative XPath
569      * @param leafrefSchemaPath
570      *            Schema Path for Leafref
571      * @return list of QName
572      */
573     private static Iterable<QName> resolveRelativeXPath(final SchemaContext context, final Module module,
574             final RevisionAwareXPath relativeXPath, final SchemaNode leafrefParentNode) {
575         Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
576         Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
577         Preconditions.checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
578         Preconditions.checkState(!relativeXPath.isAbsolute(),
579                 "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
580                         + "for non relative Revision Aware XPath use findDataSchemaNode method");
581         Preconditions.checkState(leafrefParentNode.getPath() != null,
582                 "Schema Path reference for Leafref cannot be NULL");
583
584         final Iterable<String> xpaths = SLASH_SPLITTER.split(relativeXPath.toString());
585
586         // Find out how many "parent" components there are
587         // FIXME: is .contains() the right check here?
588         int colCount = 0;
589         for (Iterator<String> it = xpaths.iterator(); it.hasNext() && it.next().contains(".."); ) {
590             ++colCount;
591         }
592
593         final Iterable<QName> parent = leafrefParentNode.getPath().getPathFromRoot();
594         return Iterables.concat(Iterables.limit(parent, Iterables.size(parent) - colCount),
595                 Iterables.transform(Iterables.skip(xpaths, colCount), new Function<String, QName>() {
596                     @Override
597                     public QName apply(final String input) {
598                         return stringPathPartToQName(context, module, input);
599                     }
600                 }));
601     }
602 }