use of de.pdark.decentxml.XMLParseException in project sling by apache.
the class JcrNode method initChildren.
void initChildren() {
try {
if (resourceChildrenAdded) {
throw new IllegalStateException("Children already loaded");
}
Set<String> childrenNames = new HashSet<>();
for (Iterator<JcrNode> it = children.iterator(); it.hasNext(); ) {
JcrNode node = it.next();
childrenNames.add(node.getName());
}
if (resource != null && resource instanceof IFolder) {
IFolder folder = (IFolder) resource;
IResource[] members = folder.members();
List<IResource> membersList = new LinkedList<>(Arrays.asList(members));
outerLoop: while (membersList.size() > 0) {
for (Iterator<IResource> it = membersList.iterator(); it.hasNext(); ) {
IResource iResource = it.next();
if (isDotVltFile(iResource)) {
it.remove();
continue;
}
if (childShouldNotBeShown(iResource)) {
it.remove();
continue;
}
if (isVaultFile(iResource)) {
GenericJcrRootFile gjrf;
try {
gjrf = new GenericJcrRootFile(this, (IFile) iResource);
it.remove();
// gjrf.getChildren();
gjrf.pickResources(membersList);
} catch (XMLParseException e) {
// don't try to parse it
// errors will be reported by the XML validation infrastructure
it.remove();
}
// add them if they're not already added
for (JcrNode node : children) {
if (!childrenNames.contains(node.getName())) {
childrenNames.add(node.getName());
}
}
continue outerLoop;
}
}
List<JcrNode> newNodes = new LinkedList<>();
for (Iterator<IResource> it = membersList.iterator(); it.hasNext(); ) {
IResource iResource = (IResource) it.next();
JcrNode node;
if (DirNode.isDirNode(iResource)) {
node = new DirNode(this, (Element) null, iResource);
} else {
node = new JcrNode(this, (Element) null, iResource);
}
childrenNames.add(node.getName());
newNodes.add(node);
it.remove();
}
}
}
resourceChildrenAdded = true;
} catch (CoreException e) {
e.printStackTrace();
org.apache.sling.ide.eclipse.ui.internal.Activator.getDefault().getPluginLogger().error("Error initializing children: " + e, e);
} catch (ParserConfigurationException e) {
e.printStackTrace();
org.apache.sling.ide.eclipse.ui.internal.Activator.getDefault().getPluginLogger().error("Error initializing children: " + e, e);
} catch (SAXException e) {
e.printStackTrace();
org.apache.sling.ide.eclipse.ui.internal.Activator.getDefault().getPluginLogger().error("Error initializing children: " + e, e);
} catch (IOException e) {
e.printStackTrace();
org.apache.sling.ide.eclipse.ui.internal.Activator.getDefault().getPluginLogger().error("Error initializing children: " + e, e);
}
}
use of de.pdark.decentxml.XMLParseException in project sling by apache.
the class TolerantXMLTokenizer method parseAttribute.
@Override
protected void parseAttribute(Token token) {
token.setType(Type.ATTRIBUTE);
parseName("attribute");
if (pos == token.getStartOffset())
throw new XMLParseException("Expected attribute name", source, pos);
skipWhiteSpace();
expect('=');
skipWhiteSpace();
char c = 0;
if (pos < source.length())
c = source.charAt(pos);
if (c != '\'' && c != '"')
throw new XMLParseException("Expected single or double quotes", source, pos);
char endChar = c;
while (true) {
pos++;
if (pos >= source.length()) {
int i = Math.min(20, source.length() - token.getStartOffset());
throw new XMLParseException("Missing end quote (" + endChar + ") of attribute: " + lookAheadForErrorMessage(null, token.getStartOffset(), i), token);
}
c = source.charAt(pos);
if (c == endChar)
break;
if (c == '<') {
Location l = new Location(source, pos);
System.err.println("Illegal character in attribute value: '" + c + "' in " + originDetails + " at " + l);
}
}
// Skip end-char
pos++;
}
Aggregations