List of usage examples for org.jdom2 Namespace XML_NAMESPACE
Namespace XML_NAMESPACE
To view the source code for org.jdom2 Namespace XML_NAMESPACE.
Click Source Link
Namespace
for the standard xml prefix. From source file:es.upm.dit.xsdinferencer.generation.generatorimpl.schemageneration.XMLSchemaDocumentGenerator.java
License:Apache License
/** * It generates the XSD file of the targetNamespace given at the constructor, taking into account that * the main namespace is the one given at the constructor. * /* w w w . jav a2 s . co m*/ * @param schema the schema object * @param configuration the inference configuration * * @return a JDOM2 {@link Document} object containing the XSD contents. * * @see SchemaDocumentGenerator#generateSchemaDocument(Schema, XSDInferenceConfiguration) */ @Override public Document generateSchemaDocument(Schema schema, XSDInferenceConfiguration configuration) { // if(!configuration.getElementsGlobal()==false || // !configuration.getComplexTypesGlobal()==true || // !configuration.getSimpleTypesGlobal()==true // ) // throw new UnsupportedOperationException("Not implemented yet."); // checkArgument(schema.getNamespacesToPossiblePrefixMappingModifiable().containsKey(mainNamespace), "The main namespace must be a known namespace"); checkArgument(schema.getNamespacesToPossiblePrefixMappingModifiable().containsKey(targetNamespace), "The target namespace must be a known namespace"); // checkArgument(!schema.getNamespacesToPossiblePrefixMappingModifiable().containsKey(XSD_NAMESPACE_URI),"The XSD namespace must not be a known namespace"); // checkArgument(!schema.getNamespacesToPossiblePrefixMappingModifiable().containsKey(XSI_NAMESPACE_URI),"The XSI namespace must not be a known namespace"); Map<String, String> namespaceURIToPrefixMappings = schema.getSolvedNamespaceMappings(); if (configuration.getSkipNamespaces().contains(targetNamespace)) { throw new IllegalArgumentException("This is an skipped namespace, so its XSD should not be generated"); } if (targetNamespace.equals(XSD_NAMESPACE_URI)) System.err.println( "The XML Schema namespace is being considered as a target namespace in your documents. Independing of the inferred schemas, the only valid XSD for an XSD would be the normative one present at its first RFC"); Namespace xsdNamespace = Namespace.getNamespace(XSD_NAMESPACE_PREFIX.replace(":", ""), XSD_NAMESPACE_URI); List<Namespace> namespaceDeclarations = getNamespaceDeclarations(namespaceURIToPrefixMappings, xsdNamespace); Element elementSchema = new Element("schema", xsdNamespace); for (int i = 0; i < namespaceDeclarations.size(); i++) { Namespace currentNamespace = namespaceDeclarations.get(i); elementSchema.addNamespaceDeclaration(currentNamespace); String currentNamespaceUri = currentNamespace.getURI(); if (!targetNamespace.equals(mainNamespace) && !currentNamespaceUri.equals(mainNamespace)) continue; if (currentNamespace.equals(Namespace.XML_NAMESPACE) && (!schema.getAttributes().containsRow(XSDInferenceConfiguration.XML_NAMESPACE_URI) && !schema.getElements().containsRow(XSDInferenceConfiguration.XML_NAMESPACE_URI))) { continue; } if (currentNamespaceUri.equals(XSD_NAMESPACE_URI) && !namespaceURIToPrefixMappings.containsKey(XSD_NAMESPACE_URI)) continue; if (targetNamespace.equals(currentNamespaceUri) || (currentNamespaceUri.equals("") && (fileNameGenerator == null))) continue; if (currentNamespaceUri.equals("") && !currentNamespaceUri.equals(mainNamespace) && !schema.getElements().containsRow("")) continue; Element importElement = new Element("import", xsdNamespace); if (!currentNamespaceUri.equals("")) { Attribute namespaceAttr = new Attribute("namespace", currentNamespaceUri); importElement.setAttribute(namespaceAttr); } if (fileNameGenerator != null && !configuration.getSkipNamespaces().contains(currentNamespaceUri)) { String fileName = fileNameGenerator.getSchemaDocumentFileName(currentNamespaceUri, namespaceURIToPrefixMappings); Attribute schemaLocationAttr = new Attribute("schemaLocation", fileName); importElement.setAttribute(schemaLocationAttr); } elementSchema.addContent(importElement); } if (!targetNamespace.equals("")) { Attribute targetNamespaceAttr = new Attribute("targetNamespace", targetNamespace); elementSchema.setAttribute(targetNamespaceAttr); } SortedSet<SimpleType> sortedSimpleTypes = new TreeSet<>(new SimpleTypeComparator()); sortedSimpleTypes.addAll(schema.getSimpleTypes().values()); SortedSet<ComplexType> sortedComplexTypes = new TreeSet<>(new ComplexTypeComparator()); sortedComplexTypes.addAll(schema.getComplexTypes().values()); //CONTINUE FROM HERE: Generate sorted sets for SchemaElement and SchemaAttribute objects and use them where needed. Attribute elementFormDefault = new Attribute("elementFormDefault", "qualified"); elementSchema.setAttribute(elementFormDefault); Document resultingDocument = new Document(elementSchema); if (targetNamespace.equals(mainNamespace)) { //First, we declare global SimpleTypes. //If simpleTypesGlobal is true, any enumeration will be declared as a global simple type. //if not, simple types of complex types which have attributes but not children will be declared globally //(due to limitations of XSD, they may not be declared locally together with the attributes info) if (configuration.getSimpleTypesGlobal()) { for (SimpleType simpleType : sortedSimpleTypes) { if (!simpleType.isEnum() || simpleType.isEmpty()) continue; Element simpleTypeElement = generateSimpleType(simpleType, false, configuration, xsdNamespace); elementSchema.addContent(simpleTypeElement); } } else { for (ComplexType complexType : sortedComplexTypes) { SimpleType simpleType = complexType.getTextSimpleType(); if (complexType.getAttributeList().isEmpty() || !(complexType.getAutomaton().nodeCount() == 0) || !simpleType.isEnum() || simpleType.isEmpty()) continue; Element simpleTypeElement = generateSimpleType(simpleType, false, configuration, xsdNamespace); elementSchema.addContent(simpleTypeElement); } } //Global complexType elements are only generated in the main schema (i.e. the one whose targetNamespace is equal to mainNamespace) if (configuration.getComplexTypesGlobal()) { for (ComplexType complexType : sortedComplexTypes) { boolean hasNoChildren = complexType.getRegularExpression().equals(new EmptyRegularExpression()); boolean hasNoAttributes = complexType.getAttributeList().size() == 0; boolean hasNoComments = complexType.getComments().size() == 0; // boolean simpleTypeIsNotEmpty = !complexType.getTextSimpleType().isEmpty(); boolean simpleTypeIsWhiteSpaceOnlyOrEmpty = !(complexType.getTextSimpleType().isEmpty() || complexType.getTextSimpleType().consistOnlyOfWhitespaceCharacters()); if (hasNoChildren && hasNoAttributes && simpleTypeIsWhiteSpaceOnlyOrEmpty && hasNoComments) continue; //Because the elements which are linked to this ComplexType at our internal model //will be linked to an XSD simple type elsewhere, either a builtin or a custom one. Element complexTypeElement = generateComplexType(configuration, complexType, false, targetNamespace, namespaceURIToPrefixMappings, mainNamespace, xsdNamespace); elementSchema.addContent(complexTypeElement); } } } //If there are many namespaces and the workaround is disabled, we must declare global attributes. //If the targetNamespace is not the mainNamespace, we must declare all the attributes. //if the target namespace is the main namespace, we do not need to declare anything, because the complex types which hold the attributes //are also in the main namespace. if ((namespaceURIToPrefixMappings.size() - configuration.getSkipNamespaces().size()) > 1) { SortedMap<String, SchemaAttribute> globalAttributeCandidates = new TreeMap<>( schema.getAttributes().row(targetNamespace)); if (!targetNamespace.equals(mainNamespace) && !targetNamespace.equals("")) { globalAttributesLoop: for (Map.Entry<String, SchemaAttribute> schemaAttributeEntry : globalAttributeCandidates .entrySet()) { SchemaAttribute schemaAttribute = schemaAttributeEntry.getValue(); //First, we check if the attribute has been already declared when the workaround is disabled. //If so, we update the "use" property. //The type should have been already merged. if (!configuration.getStrictValidRootDefinitionWorkaround()) { List<Element> alreadyGeneratedAttributeElements = elementSchema.getChildren("attribute", xsdNamespace); for (int i = 0; i < alreadyGeneratedAttributeElements.size(); i++) { Element currentAttributeElement = alreadyGeneratedAttributeElements.get(i); if (currentAttributeElement.getAttributeValue("name") .equals(schemaAttribute.getName())) { continue globalAttributesLoop; } } } Element attributeOrAttributeGroupElement = generateAttribute(schemaAttribute, true, configuration, namespaceURIToPrefixMappings, targetNamespace, mainNamespace, schemaAttributeEntry.getKey(), xsdNamespace); elementSchema.addContent(attributeOrAttributeGroupElement); } } } //Now, we declare global elements. //An element will be declared globally if and only if: //1-elementsGlobal is true in the configuration //2-The element is a valid root //3-The element is in a namespace other than the main namespace. Note that the element WILL be surrounded by the corresponding group if the workaround is enabled. //Another important remark: Iterating over a set copy implies iterating over DISTINCT SchemaElements, so if two keys pointed to equal SchemaElements, we would generate it only once- SortedSet<SchemaElement> schemaElementsAtTargetNamespace = new TreeSet<>(new SchemaElementComparator()); schemaElementsAtTargetNamespace.addAll(schema.getElements().row(targetNamespace).values()); globalSchemaElementsLoop: for (SchemaElement schemaElement : schemaElementsAtTargetNamespace) { // if(!configuration.getElementsGlobal()&& // !schemaElement.isValidRoot()&& // (targetNamespace.equals(mainNamespace)||configuration.getStrictValidRootDefinitionWorkaround())) if (!configuration.getElementsGlobal() && !schemaElement.isValidRoot() && (targetNamespace.equals(mainNamespace))) continue; // for(Element currentElement:elementSchema.getContent(Filters.element("element",xsdNamespace))){ // if(schemaElement.getName().equals(currentElement.getAttributeValue("name"))) // continue globalSchemaElementsLoop; // } String possibleGroupName = schemaElement.getName() + configuration.getTypeNamesAncestorsSeparator() + schemaElement.getType().getName(); for (Element currentElement : elementSchema.getContent(Filters.element("group", xsdNamespace))) { if (possibleGroupName.equals(currentElement.getAttributeValue("name"))) continue globalSchemaElementsLoop; } Element elementOrGroupElement = generateElement(schemaElement, true, configuration, targetNamespace, mainNamespace, null, namespaceURIToPrefixMappings, xsdNamespace); if (elementOrGroupElement.getName().equals("element")) { for (Element currentElement : elementSchema.getChildren("element", xsdNamespace)) { if (schemaElement.getName().equals(currentElement.getAttributeValue("name"))) continue globalSchemaElementsLoop; } } elementSchema.addContent(elementOrGroupElement); } return resultingDocument; }
From source file:es.upm.dit.xsdinferencer.generation.generatorimpl.statisticsgeneration.StatisticResultsDocGeneratorImpl.java
License:Apache License
/** * This method generates an element which contains the representation of a basic statistics entry. Depending on which basic statistics entry is going to * be represented, the element could have a different name, different identifying attributes(like path, name, namespace, value...). * @param elementName the name of the generated element * @param path the path where the entry comes from (if it comes from a path), if it is not null, a 'path' attribute is generated with this value, else, no 'path' attribute is generated. * @param name the name of the source node (if it comes from a complex type statistics entry), if it is not null, a 'name' attribute is generated with this value, else, no 'name' attribute is generated. * @param namespace the namespace of the source node (if it comes from a complex type statistics entry), if it is not null, a 'namespace' attribute is generated with this value, else, no 'namespace' attribute is generated. * @param value the value which the entry is related to (if it is related to a value), if it is not null, a 'value' child element with this value is generated (and xml:space attribute set to 'preserve'), else, no 'value' element is generated. * @param entry the entry to represent/*from w ww .jav a 2s . c o m*/ * @param generateConditionedStatistics flag to indicate whether conditioned statistics info should be generated and attached to the element * @param generateNonZeroRatio flag to indicate whether non zero ratio info should be generated and attached to the element * @return the representation of the BasicStatisticsEntry object, as a JDOM2 element */ protected Element generateBasicStatisticsEntryBasedElement(String elementName, String path, String name, String namespace, String value, BasicStatisticsEntry entry, boolean generateConditionedStatistics, boolean generateNonZeroRatio) { Element generatedElement = new Element(elementName, STATISTICS_NAMESPACE); if (path != null) { Attribute pathAttr = new Attribute("path", path); generatedElement.setAttribute(pathAttr); } if (value != null) { Element valueElement = new Element("value", STATISTICS_NAMESPACE); valueElement.setText(value); Attribute spaceAttribute = new Attribute("space", "preserve", Namespace.XML_NAMESPACE); valueElement.setAttribute(spaceAttribute); generatedElement.addContent(valueElement); } if (name != null) { Attribute nameAttr = new Attribute("name", name); generatedElement.setAttribute(nameAttr); } if (namespace != null) { Attribute namespaceAttr = new Attribute("namespace", namespace); generatedElement.setAttribute(namespaceAttr); } // Element averageElement = new Element("average", STATISTICS_NAMESPACE); // averageElement.setText(entry.getAverage()+""); // atPathElement.addContent(averageElement); Attribute averageAttribute = new Attribute("average", roundingFormat.format(entry.getAverage()) + ""); generatedElement.setAttribute(averageAttribute); Set<ValueAndFrequency> mode = entry.getMode(); if (!mode.isEmpty()) { Element modeElement = new Element("modes", STATISTICS_NAMESPACE); for (ValueAndFrequency modeValue : mode) { Element valueElement = new Element("modeValue", STATISTICS_NAMESPACE); valueElement.setText(roundingFormat.format(modeValue.getValue()) + ""); Attribute valueFreqAttr = new Attribute("frequency", modeValue.getFrequency() + ""); valueElement.setAttribute(valueFreqAttr); modeElement.addContent(valueElement); } generatedElement.addContent(modeElement); } // Element maxElement=new Element("max",STATISTICS_NAMESPACE); // ValueAndFrequency max = entry.getMax(); // maxElement.setText(max.getValue()+""); // Attribute maxFreqAttr = new Attribute("frequency", max.getFrequency()+""); // maxElement.setAttribute(maxFreqAttr); // generatedElement.addContent(maxElement); Attribute maxAttribute = new Attribute("max", roundingFormat.format(entry.getMax().getValue()) + ""); generatedElement.setAttribute(maxAttribute); Attribute maxFrequencyAttribute = new Attribute("frequencyOfMax", entry.getMax().getFrequency() + ""); generatedElement.setAttribute(maxFrequencyAttribute); // Element minElement=new Element("min",STATISTICS_NAMESPACE); // ValueAndFrequency min = entry.getMin(); // minElement.setText(min.getValue()+""); // Attribute minFreqAttr = new Attribute("frequency", min.getFrequency()+""); // minElement.setAttribute(minFreqAttr); // generatedElement.addContent(minElement); Attribute minAttribute = new Attribute("min", roundingFormat.format(entry.getMin().getValue()) + ""); generatedElement.setAttribute(minAttribute); Attribute minFrequencyAttribute = new Attribute("frequencyOfMin", entry.getMin().getFrequency() + ""); generatedElement.setAttribute(minFrequencyAttribute); // Element varianceElement = new Element("variance", STATISTICS_NAMESPACE); // varianceElement.setText(entry.getVariance()+""); // generatedElement.addContent(varianceElement); Attribute varianceAttribute = new Attribute("variance", roundingFormat.format(entry.getVariance()) + ""); generatedElement.setAttribute(varianceAttribute); // Element standardDeviationAverageRatioElement = new Element("standardDeviationAverageRatio", STATISTICS_NAMESPACE); // standardDeviationAverageRatioElement.setText(entry.getStandardDeviationAverageRatio()+""); // generatedElement.addContent(standardDeviationAverageRatioElement); Attribute standardDeviationAverageRatioAttribute = new Attribute("standardDeviationAverageRatio", roundingFormat.format(entry.getStandardDeviationAverageRatio()) + ""); generatedElement.setAttribute(standardDeviationAverageRatioAttribute); if (generateConditionedStatistics) { Attribute conditionedAverageAttribute = new Attribute("conditionedAverage", roundingFormat.format(entry.getConditionedAverage()) + ""); generatedElement.setAttribute(conditionedAverageAttribute); Attribute conditionedVarianceAttribute = new Attribute("conditionedVariance", roundingFormat.format(entry.getConditionedVariance()) + ""); generatedElement.setAttribute(conditionedVarianceAttribute); Attribute conditionedStandardDeviationAverageRatioAttribute = new Attribute( "conditionedStandardDeviationAverageRatio", roundingFormat.format(entry.getConditionedStandardDeviationAverageRatio()) + ""); generatedElement.setAttribute(conditionedStandardDeviationAverageRatioAttribute); // Element conditionedStandardDeviationAverageRatioElement = new Element("conditionedStandardDeviationAverageRatio", STATISTICS_NAMESPACE); // conditionedStandardDeviationAverageRatioElement.setText(entry.getConditionedStandardDeviationAverageRatio()+""); // generatedElement.addContent(conditionedStandardDeviationAverageRatioElement); // // Element conditionedAverageElement = new Element("conditionedAverage", STATISTICS_NAMESPACE); // conditionedAverageElement.setText(entry.getConditionedAverage()+""); // generatedElement.addContent(conditionedAverageElement); // // Element conditionedVarianceElement = new Element("conditionedVariance", STATISTICS_NAMESPACE); // conditionedVarianceElement.setText(entry.getConditionedVariance()+""); // generatedElement.addContent(conditionedVarianceElement); } if (generateNonZeroRatio) { Attribute nonZeroRatioAttribute = new Attribute("presenceRatio", roundingFormat.format(entry.getNonZeroRatio()) + ""); generatedElement.setAttribute(nonZeroRatioAttribute); // Element nonZeroRatio = new Element("presenceRatio", STATISTICS_NAMESPACE); // nonZeroRatio.setText(""+entry.getNonZeroRatio()); // generatedElement.addContent(nonZeroRatio); } // Element totalElement = new Element("total", STATISTICS_NAMESPACE); // totalElement.setText(entry.getTotal()+""); // generatedElement.addContent(totalElement); Attribute totalAttribute = new Attribute("total", roundingFormat.format(entry.getTotal()) + ""); generatedElement.setAttribute(totalAttribute); return generatedElement; }
From source file:eu.himeros.hocr.HocrInfoAggregator.java
License:Open Source License
private void makeCompliantHocr() { xpath = XPathFactory.instance().compile("//ns:span[@id|@idx]", Filters.element(), null, Namespace.getNamespace("ns", "http://www.w3.org/1999/xhtml")); List<Element> elements = xpath.evaluate(root); int spanId = 0; for (Element span : elements) { if (span.getAttribute("idx") != null) { try { span = span.getChildren().get(0); } catch (Exception ex) { // }// ww w . j a v a2s .c om } LinkedList<Attribute> attributeLl = new LinkedList(span.getParentElement().getAttributes()); attributeLl.addFirst(new Attribute("id", "w_" + spanId++)); span.getParentElement().setAttributes(attributeLl); String[] suggestions = null; String title = span.getAttributeValue("title"); if (title != null) { suggestions = title.split(" "); } if (suggestions == null) { suggestions = new String[] { "" }; } Element ins = new Element("ins", xmlns); ins.setAttribute("class", "alt"); ins.setAttribute("title", makeNlp(span.getAttributeValue("class"))); ins.setText(span.getText()); span.removeContent(); span.addContent(ins); span.setAttribute("class", "alternatives"); span.removeAttribute("uc"); span.removeAttribute("occ"); span.removeAttribute("title"); span.removeAttribute("anchor"); span.removeAttribute("anchor-id"); span.removeAttribute("id"); span.getParentElement().removeAttribute("idx"); span.removeAttribute("whole"); span.getParentElement().removeAttribute("whole"); if (title == null || "".equals(title)) { continue; } double score = 0.90; for (String suggestion : suggestions) { if (suggestion == null || "".equals(suggestion)) { continue; } Element del = new Element("del", xmlns); del.setAttribute("title", "nlp " + String.format("%.2f", score).replaceAll(",", ".")); score = score - 0.01; suggestion = suggestion.replaceAll(l1PunctMarkFilter, ""); Matcher leftMatcher = l1LeftPunctMarkPattern.matcher(ins.getText()); if (leftMatcher.matches()) { suggestion = leftMatcher.group(1) + suggestion; } Matcher rightMatcher = l1RightPunctMarkPattern.matcher(ins.getText()); if (rightMatcher.matches()) { String ngtSymbol = ""; if (suggestion.endsWith("\u261a")) { ngtSymbol = "\u261a"; suggestion = suggestion.substring(0, suggestion.length() - 1); } suggestion = suggestion + rightMatcher.group(1) + ngtSymbol; } ///!!!! if (suggestion.endsWith("\u261a") && ins.getParentElement().getParentElement() .getAttributeValue("lang", Namespace.XML_NAMESPACE) != null) { String buff = suggestion.substring(0, suggestion.length() - 1); sa.align(buff, ins.getText()); double sim = 1 - sa.getEditDistance() / Math.max((double) buff.length(), (double) ins.getText().length()); if (sim > 0.6) { suggestion = ins.getText() + "\u261b"; ins.setText(buff); ins.setAttribute("title", "nlp 0.70"); } } del.addContent(suggestion); span.addContent(del); } } }
From source file:nl.colorize.util.xml.XMLHelper.java
License:Apache License
/** * Requests whitespace in {@code element}'s text to be preserved when printed. * This will add the attribute {@code xml:space="preserve"}. */// w w w . ja va2 s .c o m public static Element preserveWhitespace(Element element) { element.setAttribute("space", "preserve", Namespace.XML_NAMESPACE); return element; }
From source file:org.mycore.datamodel.classifications2.utils.MCREditorItemComparator.java
License:Open Source License
@SuppressWarnings("unchecked") private static String getCurrentLangLabel(Element item, String language) { List<Element> labels = item.getChildren("label"); for (Element label : labels) { if (label.getAttributeValue("lang", Namespace.XML_NAMESPACE).equals(language)) { return label.getText(); }/* ww w. j a v a 2 s .c o m*/ } if (labels.size() > 0) { //fallback to first label if currentLang label is not found return labels.get(0).getText(); } return ""; }
From source file:org.mycore.datamodel.classifications2.utils.MCRXMLTransformer.java
License:Open Source License
public static MCRLabel getLabel(Element labelElement) throws NullPointerException, IllegalArgumentException { String lang = labelElement.getAttributeValue("lang", Namespace.XML_NAMESPACE); MCRLabel label = new MCRLabel(lang, labelElement.getAttributeValue("text"), labelElement.getAttributeValue("description")); return label; }
From source file:org.mycore.datamodel.ifs2.MCRStoredNode.java
License:Open Source License
/** * Sets a label for this node/*from w ww . ja v a 2s .c o m*/ * * @param lang * the xml:lang language ID * @param label * the label in this language */ public void setLabel(String lang, String label) throws IOException { data.getChildren(LABEL_ELEMENT).stream() .filter(child -> lang.equals(child.getAttributeValue(LANG_ATT, Namespace.XML_NAMESPACE))).findAny() .orElseGet(() -> { Element newLabel = new Element(LABEL_ELEMENT).setAttribute(LANG_ATT, lang, Namespace.XML_NAMESPACE); data.addContent(newLabel); return newLabel; }).setText(label); getRoot().saveAdditionalData(); }
From source file:org.mycore.datamodel.ifs2.MCRStoredNode.java
License:Open Source License
/** * Returns a map of all labels, sorted by xml:lang, Key is xml:lang, value * is the label for that language./*ww w . ja v a 2 s .c o m*/ */ public Map<String, String> getLabels() { Map<String, String> labels = new TreeMap<String, String>(); for (Element label : (List<Element>) data.getChildren(LABEL_ELEMENT)) { labels.put(label.getAttributeValue(LANG_ATT, Namespace.XML_NAMESPACE), label.getText()); } return labels; }
From source file:org.mycore.datamodel.ifs2.MCRStoredNode.java
License:Open Source License
/** * Returns the label in the given language * // www.j ava 2 s . com * @param lang * the xml:lang language ID * @return the label, or null if there is no label for that language */ public String getLabel(String lang) { return data.getChildren(LABEL_ELEMENT).stream() .filter(label -> lang.equals(label.getAttributeValue(LANG_ATT, Namespace.XML_NAMESPACE))).findAny() .map(Element::getText).orElse(null); }
From source file:org.mycore.datamodel.language.MCRLanguageXML.java
License:Open Source License
/** * Sets the xml:lang attribute to the ISO 639-1 code of the given language *//*from w w w . j a v a 2s . co m*/ public static void setXMLLangAttribute(MCRLanguage lang, Element element) { element.setAttribute("lang", lang.getCode(MCRLanguageCodeType.xmlCode), Namespace.XML_NAMESPACE); }