- if (dsn instanceof ChoiceNode) {
- choiceSubnodes.put(dsn.getQName().getLocalName(), (ChoiceNode) dsn);
- } else if (node.getNodeType().getLocalName().equals(dsn.getQName().getLocalName())) {
- return new SchemaLocation(dsn);
- }
- }
-
- for (ChoiceNode choiceSubnode : choiceSubnodes.values()) {
- if ((!pathIterator.isEmpty() && pathIterator.peekLast().equals(choiceSubnode.getQName().getLocalName()))
- || pathIterator.isEmpty()) {
- String pathPartChoice = pathIterator.pollLast();
- for (ChoiceCaseNode concreteCase : choiceSubnode.getCases()) {
- if ((!pathIterator.isEmpty() && pathIterator.peekLast().equals(
- concreteCase.getQName().getLocalName()))
- || pathIterator.isEmpty()) {
- String pathPartCase = pathIterator.pollLast();
- SchemaLocation schemaLocation = findFirstSchemaForNode(node, concreteCase.getChildNodes(),
- pathIterator);
- if (schemaLocation != null) {
- schemaLocation.addPathPart(concreteCase.getQName().getLocalName());
- schemaLocation.addPathPart(choiceSubnode.getQName().getLocalName());
- return schemaLocation;
- }
- if (pathPartCase != null) {
- pathIterator.addLast(pathPartCase);
- }
+ if (node.getNodeType().getLocalName().equals(dsn.getQName().getLocalName())) {
+ return dsn;
+ } else if (dsn instanceof ChoiceNode) {
+ for (ChoiceCaseNode choiceCase : ((ChoiceNode) dsn).getCases()) {
+ DataSchemaNode foundDsn = findFirstSchemaForNode(node, choiceCase.getChildNodes());
+ if (foundDsn != null) {
+ return foundDsn;