List of usage examples for org.jdom2 Namespace getNamespace
public static Namespace getNamespace(final String uri)
Namespace
for the supplied URI, and make it usable as a default namespace, as no prefix is supplied. From source file:org.goobi.production.export.ExportXmlLog.java
License:Open Source License
/** * This method creates a new xml document with process metadata * /*w ww .java 2 s.com*/ * @param process the process to export * @return a new xml document * @throws ConfigurationException */ public Document createDocument(Process process, boolean addNamespace) { Element processElm = new Element("process"); Document doc = new Document(processElm); processElm.setAttribute("processID", String.valueOf(process.getId())); Namespace xmlns = Namespace.getNamespace("http://www.goobi.io/logfile"); processElm.setNamespace(xmlns); // namespace declaration if (addNamespace) { Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); processElm.addNamespaceDeclaration(xsi); Attribute attSchema = new Attribute("schemaLocation", "http://www.goobi.io/logfile" + " XML-logfile.xsd", xsi); processElm.setAttribute(attSchema); } // process information ArrayList<Element> processElements = new ArrayList<>(); Element processTitle = new Element("title", xmlns); processTitle.setText(process.getTitel()); processElements.add(processTitle); Element project = new Element("project", xmlns); project.setText(process.getProjekt().getTitel()); processElements.add(project); Element date = new Element("time", xmlns); date.setAttribute("type", "creation date"); date.setText(String.valueOf(process.getErstellungsdatum())); processElements.add(date); Element ruleset = new Element("ruleset", xmlns); ruleset.setText(process.getRegelsatz().getDatei()); processElements.add(ruleset); Element comment = new Element("comments", xmlns); List<LogEntry> log = process.getProcessLog(); for (LogEntry entry : log) { Element commentLine = new Element("comment", xmlns); commentLine.setAttribute("type", entry.getType().getTitle()); commentLine.setAttribute("user", entry.getUserName()); commentLine.setText(entry.getContent()); if (StringUtils.isNotBlank(entry.getSecondContent())) { comment.setAttribute("secondField", entry.getSecondContent()); } if (StringUtils.isNotBlank(entry.getThirdContent())) { comment.setAttribute("thirdField", entry.getThirdContent()); } comment.addContent(commentLine); } processElements.add(comment); if (process.getBatch() != null) { Element batch = new Element("batch", xmlns); batch.setText(String.valueOf(process.getBatch().getBatchId())); if (StringUtils.isNotBlank(process.getBatch().getBatchName())) { batch.setAttribute("batchName", process.getBatch().getBatchName()); } if (process.getBatch().getStartDate() != null) { batch.setAttribute("startDate", Helper.getDateAsFormattedString(process.getBatch().getStartDate())); } if (process.getBatch().getEndDate() != null) { batch.setAttribute("endDate", Helper.getDateAsFormattedString(process.getBatch().getEndDate())); } processElements.add(batch); } List<Element> processProperties = new ArrayList<>(); List<ProcessProperty> propertyList = PropertyParser.getInstance().getPropertiesForProcess(process); for (ProcessProperty prop : propertyList) { Element property = new Element("property", xmlns); property.setAttribute("propertyIdentifier", prop.getName()); if (prop.getValue() != null) { property.setAttribute("value", prop.getValue()); } else { property.setAttribute("value", ""); } Element label = new Element("label", xmlns); label.setText(prop.getName()); property.addContent(label); processProperties.add(property); } if (processProperties.size() != 0) { Element properties = new Element("properties", xmlns); properties.addContent(processProperties); processElements.add(properties); } // step information Element steps = new Element("steps", xmlns); List<Element> stepElements = new ArrayList<>(); for (Step s : process.getSchritteList()) { Element stepElement = new Element("step", xmlns); stepElement.setAttribute("stepID", String.valueOf(s.getId())); Element steptitle = new Element("title", xmlns); steptitle.setText(s.getTitel()); stepElement.addContent(steptitle); Element state = new Element("processingstatus", xmlns); state.setText(s.getBearbeitungsstatusAsString()); stepElement.addContent(state); Element begin = new Element("time", xmlns); begin.setAttribute("type", "start time"); begin.setText(s.getBearbeitungsbeginnAsFormattedString()); stepElement.addContent(begin); Element end = new Element("time", xmlns); end.setAttribute("type", "end time"); end.setText(s.getBearbeitungsendeAsFormattedString()); stepElement.addContent(end); if (s.getBearbeitungsbenutzer() != null && s.getBearbeitungsbenutzer().getNachVorname() != null) { Element user = new Element("user", xmlns); user.setText(s.getBearbeitungsbenutzer().getNachVorname()); stepElement.addContent(user); } Element editType = new Element("edittype", xmlns); editType.setText(s.getEditTypeEnum().getTitle()); stepElement.addContent(editType); stepElements.add(stepElement); } if (stepElements != null) { steps.addContent(stepElements); processElements.add(steps); } // template information Element templates = new Element("originals", xmlns); List<Element> templateElements = new ArrayList<>(); for (Template v : process.getVorlagenList()) { Element template = new Element("original", xmlns); template.setAttribute("originalID", String.valueOf(v.getId())); List<Element> templateProperties = new ArrayList<>(); for (Templateproperty prop : v.getEigenschaftenList()) { Element property = new Element("property", xmlns); property.setAttribute("propertyIdentifier", prop.getTitel()); if (prop.getWert() != null) { property.setAttribute("value", prop.getWert()); } else { property.setAttribute("value", ""); } Element label = new Element("label", xmlns); label.setText(prop.getTitel()); property.addContent(label); templateProperties.add(property); if (prop.getTitel().equals("Signatur")) { Element secondProperty = new Element("property", xmlns); secondProperty.setAttribute("propertyIdentifier", prop.getTitel() + "Encoded"); if (prop.getWert() != null) { secondProperty.setAttribute("value", "vorl:" + prop.getWert()); Element secondLabel = new Element("label", xmlns); secondLabel.setText(prop.getTitel()); secondProperty.addContent(secondLabel); templateProperties.add(secondProperty); } } } if (templateProperties.size() != 0) { Element properties = new Element("properties", xmlns); properties.addContent(templateProperties); template.addContent(properties); } templateElements.add(template); } if (templateElements != null) { templates.addContent(templateElements); processElements.add(templates); } // digital document information Element digdoc = new Element("digitalDocuments", xmlns); List<Element> docElements = new ArrayList<>(); for (Masterpiece w : process.getWerkstueckeList()) { Element dd = new Element("digitalDocument", xmlns); dd.setAttribute("digitalDocumentID", String.valueOf(w.getId())); List<Element> docProperties = new ArrayList<>(); for (Masterpieceproperty prop : w.getEigenschaftenList()) { Element property = new Element("property", xmlns); property.setAttribute("propertyIdentifier", prop.getTitel()); if (prop.getWert() != null) { property.setAttribute("value", prop.getWert()); } else { property.setAttribute("value", ""); } Element label = new Element("label", xmlns); label.setText(prop.getTitel()); property.addContent(label); docProperties.add(property); } if (docProperties.size() != 0) { Element properties = new Element("properties", xmlns); properties.addContent(docProperties); dd.addContent(properties); } docElements.add(dd); } if (docElements != null) { digdoc.addContent(docElements); processElements.add(digdoc); } // history List<HistoryEvent> eventList = HistoryManager.getHistoryEvents(process.getId()); if (eventList != null && !eventList.isEmpty()) { List<Element> eventElementList = new ArrayList<>(eventList.size()); for (HistoryEvent event : eventList) { Element element = new Element("historyEvent", xmlns); element.setAttribute("id", "" + event.getId()); element.setAttribute("date", Helper.getDateAsFormattedString(event.getDate())); element.setAttribute("type", event.getHistoryType().getTitle()); if (event.getNumericValue() != null) { element.setAttribute("numeric_value", "" + event.getNumericValue()); } if (event.getStringValue() != null) { element.setText(event.getStringValue()); } eventElementList.add(element); } if (!eventElementList.isEmpty()) { Element metadataElement = new Element("history", xmlns); metadataElement.addContent(eventElementList); processElements.add(metadataElement); } } // metadata List<StringPair> metadata = MetadataManager.getMetadata(process.getId()); if (metadata != null && !metadata.isEmpty()) { List<Element> mdlist = new ArrayList<>(); for (StringPair md : metadata) { String name = md.getOne(); String value = md.getTwo(); if (StringUtils.isNotBlank(value) && StringUtils.isNotBlank(name)) { Element element = new Element("metadata", xmlns); element.setAttribute("name", name); element.addContent(value); mdlist.add(element); } } if (!mdlist.isEmpty()) { Element metadataElement = new Element("metadatalist", xmlns); metadataElement.addContent(mdlist); processElements.add(metadataElement); } } // METS information Element metsElement = new Element("metsInformation", xmlns); List<Element> metadataElements = new ArrayList<>(); try { String filename = process.getMetadataFilePath(); Document metsDoc = new SAXBuilder().build(filename); Document anchorDoc = null; String anchorfilename = process.getMetadataFilePath().replace("meta.xml", "meta_anchor.xml"); Path anchorFile = Paths.get(anchorfilename); if (StorageProvider.getInstance().isFileExists(anchorFile) && StorageProvider.getInstance().isReadable(anchorFile)) { anchorDoc = new SAXBuilder().build(anchorfilename); } List<Namespace> namespaces = getNamespacesFromConfig(); HashMap<String, String> fields = getMetsFieldsFromConfig(false); for (String key : fields.keySet()) { List<Element> metsValues = getMetsValues(fields.get(key), metsDoc, namespaces); for (Element element : metsValues) { Element ele = new Element("property", xmlns); ele.setAttribute("name", key); ele.addContent(element.getTextTrim()); metadataElements.add(ele); } } if (anchorDoc != null) { fields = getMetsFieldsFromConfig(true); for (String key : fields.keySet()) { List<Element> metsValues = getMetsValues(fields.get(key), anchorDoc, namespaces); for (Element element : metsValues) { Element ele = new Element("property", xmlns); ele.setAttribute("name", key); ele.addContent(element.getTextTrim()); metadataElements.add(ele); } } } if (metadataElements != null) { metsElement.addContent(metadataElements); processElements.add(metsElement); } } catch (SwapException e) { logger.error(e); } catch (DAOException e) { logger.error(e); } catch (IOException e) { logger.error(e); } catch (InterruptedException e) { logger.error(e); } catch (JDOMException e) { logger.error(e); } catch (JaxenException e) { logger.error(e); } processElm.setContent(processElements); return doc; }
From source file:org.goobi.production.export.ExportXmlLog.java
License:Open Source License
/** * This method exports the production metadata for al list of processes as a single file to a given stream. * //from w w w. j a v a 2s . c o m * @param processList * @param outputStream * @param xslt */ public void startExport(List<Process> processList, OutputStream outputStream, String xslt) { Document answer = new Document(); Element root = new Element("processes"); answer.setRootElement(root); Namespace xmlns = Namespace.getNamespace("http://www.goobi.io/logfile"); Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.addNamespaceDeclaration(xsi); root.setNamespace(xmlns); Attribute attSchema = new Attribute("schemaLocation", "http://www.goobi.io/logfile" + " XML-logfile.xsd", xsi); root.setAttribute(attSchema); for (Process p : processList) { Document doc = createDocument(p, false); Element processRoot = doc.getRootElement(); processRoot.detach(); root.addContent(processRoot); } XMLOutputter outp = new XMLOutputter(); outp.setFormat(Format.getPrettyFormat()); try { outp.output(answer, outputStream); } catch (IOException e) { } finally { if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { outputStream = null; } } } }
From source file:org.kisst.cordys.caas.util.XmlNode.java
License:Open Source License
public XmlNode(String name, String namespace) { this.element = new Element(name, Namespace.getNamespace(namespace)); }
From source file:org.kisst.cordys.caas.util.XmlNode.java
License:Open Source License
/** * This method sets the namespace of this element. * // w w w.ja v a2s . c o m * @param namespace The new namespace for this element. */ public void setNamespace(String namespace) { if (StringUtil.isEmptyOrNull(namespace)) { // Remove the namespace element.removeNamespaceDeclaration(Namespace.getNamespace(namespace)); } else { element.setNamespace(Namespace.getNamespace(namespace)); } }
From source file:org.kitodo.docket.ExportXmlLog.java
License:Open Source License
/** * This method exports the production metadata for al list of processes as a * single file to a given stream.// www . ja v a 2 s .c o m * * @param docketDataList * a list of Docket data * @param outputStream * The output stream, to write the docket to. */ void startMultipleExport(Iterable<DocketData> docketDataList, OutputStream outputStream) { Document answer = new Document(); Element root = new Element("processes"); answer.setRootElement(root); Namespace xmlns = Namespace.getNamespace(NAMESPACE); Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.addNamespaceDeclaration(xsi); root.setNamespace(xmlns); Attribute attSchema = new Attribute("schemaLocation", NAMESPACE + " XML-logfile.xsd", xsi); root.setAttribute(attSchema); for (DocketData docketData : docketDataList) { Document doc = createDocument(docketData, false); Element processRoot = doc.getRootElement(); processRoot.detach(); root.addContent(processRoot); } XMLOutputter outp = new XMLOutputter(Format.getPrettyFormat()); try { outp.output(answer, outputStream); } catch (IOException e) { logger.error("Generating XML Output failed.", e); } finally { if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { logger.error("Closing the output stream failed.", e); } } } }
From source file:org.kitodo.docket.ExportXmlLog.java
License:Open Source License
/** * This method creates a new xml document with process metadata. * * @param docketData/*from ww w .ja va 2 s . com*/ * the docketData to export * @return a new xml document */ private Document createDocument(DocketData docketData, boolean addNamespace) { Element processElm = new Element("process"); final Document doc = new Document(processElm); processElm.setAttribute("processID", String.valueOf(docketData.getProcessId())); Namespace xmlns = Namespace.getNamespace(NAMESPACE); processElm.setNamespace(xmlns); // namespace declaration if (addNamespace) { Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); processElm.addNamespaceDeclaration(xsi); Attribute attSchema = new Attribute("schemaLocation", NAMESPACE + " XML-logfile.xsd", xsi); processElm.setAttribute(attSchema); } // process information ArrayList<Element> processElements = new ArrayList<>(); Element processTitle = new Element("title", xmlns); processTitle.setText(docketData.getProcessName()); processElements.add(processTitle); Element project = new Element("project", xmlns); project.setText(docketData.getProjectName()); processElements.add(project); Element date = new Element("time", xmlns); date.setAttribute("type", "creation date"); date.setText(String.valueOf(docketData.getCreationDate())); processElements.add(date); Element ruleset = new Element("ruleset", xmlns); ruleset.setText(docketData.getRulesetName()); processElements.add(ruleset); Element comment = new Element("comment", xmlns); comment.setText(docketData.getComment()); processElements.add(comment); List<Element> processProperties = prepareProperties(docketData.getProcessProperties(), xmlns); if (!processProperties.isEmpty()) { Element properties = new Element(PROPERTIES, xmlns); properties.addContent(processProperties); processElements.add(properties); } // template information ArrayList<Element> templateElements = new ArrayList<>(); Element template = new Element("original", xmlns); ArrayList<Element> templateProperties = new ArrayList<>(); if (docketData.getTemplateProperties() != null) { for (Property prop : docketData.getTemplateProperties()) { Element property = new Element(PROPERTY, xmlns); property.setAttribute(PROPERTY_IDENTIFIER, prop.getTitle()); if (prop.getValue() != null) { property.setAttribute(VALUE, replacer(prop.getValue())); } else { property.setAttribute(VALUE, ""); } Element label = new Element(LABEL, xmlns); label.setText(prop.getTitle()); property.addContent(label); templateProperties.add(property); if (prop.getTitle().equals("Signatur")) { Element secondProperty = new Element(PROPERTY, xmlns); secondProperty.setAttribute(PROPERTY_IDENTIFIER, prop.getTitle() + "Encoded"); if (prop.getValue() != null) { secondProperty.setAttribute(VALUE, "vorl:" + replacer(prop.getValue())); Element secondLabel = new Element(LABEL, xmlns); secondLabel.setText(prop.getTitle()); secondProperty.addContent(secondLabel); templateProperties.add(secondProperty); } } } } if (!templateProperties.isEmpty()) { Element properties = new Element(PROPERTIES, xmlns); properties.addContent(templateProperties); template.addContent(properties); } templateElements.add(template); Element templates = new Element("originals", xmlns); templates.addContent(templateElements); processElements.add(templates); // digital document information ArrayList<Element> docElements = new ArrayList<>(); Element dd = new Element("digitalDocument", xmlns); List<Element> docProperties = prepareProperties(docketData.getWorkpieceProperties(), xmlns); if (!docProperties.isEmpty()) { Element properties = new Element(PROPERTIES, xmlns); properties.addContent(docProperties); dd.addContent(properties); } docElements.add(dd); Element digdoc = new Element("digitalDocuments", xmlns); digdoc.addContent(docElements); processElements.add(digdoc); processElm.setContent(processElements); return doc; }
From source file:org.mycore.frontend.export.MCRExportCollection.java
License:Open Source License
/** Sets the name and namespace of the root element that wraps the collected data */ public void setRootElement(String elementName, String namespaceURI) { collection.setName(elementName);//from w w w . j a v a2s . c o m if ((namespaceURI != null) && (!namespaceURI.isEmpty())) collection.setNamespace(Namespace.getNamespace(namespaceURI)); }
From source file:org.onosproject.provider.netconf.flow.impl.XmlBuilder.java
License:Apache License
public String buildAclRequestXml(AccessList accessList) { Document doc = new Document(); Namespace namespaceRpc = Namespace.getNamespace("urn:ietf:params:xml:ns:netconf:base:1.0"); Namespace accessNamespaceRpc = Namespace.getNamespace("urn:ietf:params:xml:ns:yang:ietf-acl"); doc.setRootElement(new Element("rpc", namespaceRpc).setAttribute("message-id", "101")); /**/*w w w . java2 s . c om*/ * Access list elements of given ACL model. */ Element access = new Element("access-list", accessNamespaceRpc); access.addContent(new Element("acl-name", accessNamespaceRpc).setText(accessList.getAclName())); // access.addContent(accessEntries); if (!accessList.getAccessListEntries().isEmpty() && accessList.getAccessListEntries() != null) { for (int accessEntryIntVlu = 0; accessEntryIntVlu < accessList.getAccessListEntries() .size(); accessEntryIntVlu++) { access.addContent(getAccessEntries(accessEntryIntVlu, accessList, accessNamespaceRpc)); } } /** * edit-config operation for given ACL model. */ Element editConfig = new Element("edit-config", namespaceRpc); editConfig.addContent(new Element("target", namespaceRpc).addContent(new Element("running", namespaceRpc))); editConfig .addContent(new Element("config", Namespace.getNamespace("urn:ietf:params:xml:ns:netconf:base:1.0")) .addContent(access)); doc.getRootElement().addContent(editConfig); XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat()); String outputString = xmlOutputter.outputString(doc); return outputString; }
From source file:org.richfaces.examples.richrates.RatesBean.java
License:Open Source License
/** * Downloads an XML file from European Central Bank containing exchange rates for over 30 currencies for las 90 days * and parses it.// ww w . ja v a 2s. c o m */ private void getRates() { logger.info("Parsing exchange rates"); try { // TODO put into external file // http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml // http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml // http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml URL url = new URL("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml"); Document document = new SAXBuilder().build(url); // TODO put into external file Namespace namespace = Namespace.getNamespace("http://www.ecb.int/vocabulary/2002-08-01/eurofxref"); // TODO use XPath instead of the following line List<Element> dateElements = (List<Element>) document.getRootElement().getChild("Cube", namespace) .getChildren("Cube", namespace); String timeAttribute = null; Date date = null; // get newest date timeAttribute = dateElements.iterator().next().getAttributeValue("time"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setTimeZone(timeZone); issueDate = sdf.parse(timeAttribute); for (Element e : dateElements) { timeAttribute = e.getAttributeValue("time"); date = sdf.parse(timeAttribute); List<Element> children = (List<Element>) e.getChildren("Cube", namespace); Map<String, Double> oneDayRates = new HashMap<String, Double>(); for (Element node : children) { String currency = node.getAttributeValue("currency"); double rate = node.getAttribute("rate").getDoubleValue(); oneDayRates.put(currency, rate); } currencies.put(date, oneDayRates); } logger.info("List with exchange rates parsed"); } catch (JDOMException e) { logger.log(Level.SEVERE, "Could not parse XML with exchange rates"); e.printStackTrace(); } catch (ParseException e) { logger.log(Level.SEVERE, "Could not parse date format"); e.printStackTrace(); } catch (MalformedURLException e) { logger.log(Level.SEVERE, "Could not parse the URL with exchange rates"); e.printStackTrace(); } catch (IOException e) { logger.log(Level.SEVERE, "An I/O error prevents a document from being fully parsed"); e.printStackTrace(); } }
From source file:org.rometools.feed.module.sle.io.ItemParser.java
License:Apache License
/** * Parses the XML node (JDOM element) extracting module information. * <p>//from www. ja v a 2 s. c o m * * @param element the XML node (JDOM element) to extract module information from. * @return a module instance, <b>null</b> if the element did not have module information. */ public Module parse(Element element) { SleEntryImpl sle = new SleEntryImpl(); ArrayList values = new ArrayList(); List groups = element.getChildren("group", ModuleParser.TEMP); for (int i = 0; (groups != null) && (i < groups.size()); i++) { Element group = (Element) groups.get(i); StringValue value = new StringValue(); value.setElement(group.getAttributeValue("element")); value.setLabel(group.getAttributeValue("label")); value.setValue(group.getAttributeValue("value")); if (group.getAttributeValue("ns") != null) value.setNamespace(Namespace.getNamespace(group.getAttributeValue("ns"))); else { value.setNamespace(element.getDocument().getRootElement().getNamespace()); } values.add(value); element.removeContent(group); } sle.setGroupValues((EntryValue[]) values.toArray(new EntryValue[values.size()])); values = (values.size() == 0) ? values : new ArrayList(); List sorts = new ArrayList(element.getChildren("sort", ModuleParser.TEMP)); //System.out.println("]]] sorts on element"+sorts.size()); for (int i = 0; (sorts != null) && (i < sorts.size()); i++) { Element sort = (Element) sorts.get(i); String dataType = sort.getAttributeValue("data-type"); //System.out.println("Doing datatype "+dataType +" :: "+sorts.size()); if ((dataType == null) || dataType.equals(Sort.TEXT_TYPE)) { StringValue value = new StringValue(); value.setElement(sort.getAttributeValue("element")); value.setLabel(sort.getAttributeValue("label")); value.setValue(sort.getAttributeValue("value")); if (sort.getAttributeValue("ns") != null) value.setNamespace(Namespace.getNamespace(sort.getAttributeValue("ns"))); else value.setNamespace(element.getDocument().getRootElement().getNamespace()); values.add(value); element.removeContent(sort); } else if (dataType.equals(Sort.DATE_TYPE)) { DateValue value = new DateValue(); value.setElement(sort.getAttributeValue("element")); value.setLabel(sort.getAttributeValue("label")); if (sort.getAttributeValue("ns") != null) value.setNamespace(Namespace.getNamespace(sort.getAttributeValue("ns"))); else value.setNamespace(element.getDocument().getRootElement().getNamespace()); Date dateValue = null; try { dateValue = DateParser.parseRFC822(sort.getAttributeValue("value")); dateValue = (dateValue == null) ? DateParser.parseW3CDateTime(sort.getAttributeValue("value")) : dateValue; } catch (Exception e) { ; // ignore parse exceptions } value.setValue(dateValue); values.add(value); element.removeContent(sort); } else if (dataType.equals(Sort.NUMBER_TYPE)) { NumberValue value = new NumberValue(); value.setElement(sort.getAttributeValue("element")); value.setLabel(sort.getAttributeValue("label")); if (sort.getAttributeValue("ns") != null) value.setNamespace(Namespace.getNamespace(sort.getAttributeValue("ns"))); else value.setNamespace(element.getDocument().getRootElement().getNamespace()); try { value.setValue(new BigDecimal(sort.getAttributeValue("value"))); } catch (NumberFormatException nfe) { ; // ignore values.add(value); element.removeContent(sort); } } else { throw new RuntimeException("Unknown datatype"); } } //System.out.println("Values created "+values.size()+" from sorts" +sorts.size()); sle.setSortValues((EntryValue[]) values.toArray(new EntryValue[values.size()])); return sle; }