Example usage for javax.xml.namespace QName QName

List of usage examples for javax.xml.namespace QName QName

Introduction

In this page you can find the example usage for javax.xml.namespace QName QName.

Prototype

public QName(String localPart) 

Source Link

Document

QName constructor specifying the local part.

If the local part is null an IllegalArgumentException is thrown.

Usage

From source file:com.c4om.autoconf.ulysses.configanalyzer.guilauncher.TemporaryChangesetFilesSavingGUILauncher.java

/**
 * This method generates the catalog file and stores it into the temporary folder
 * @param temporaryFolder the temporary folder
 * @param changesetPaths URIs poiting to changeset files
 * @throws CatalogGenerationException if there is any problem at catalog generation
 *///from   w  w w . j  ava 2 s . c o  m
private void generateCatalog(File temporaryFolder, List<URI> changesetPaths) throws CatalogGenerationException {
    try {
        Map<QName, List<URI>> variables = ImmutableMap.of(new QName(FILES_PARAMETER_NAME), changesetPaths);
        String catalogFileString = saxonQuery(generateCatalogQuery, variables);
        FileOutputStream fileOutputStream = new FileOutputStream(
                new File(temporaryFolder, CATALOG_XML_FILE_NAME));
        Writer writer = new XmlStreamWriter(fileOutputStream, "UTF-8");
        writer.write(catalogFileString);
        writer.close();
    } catch (IOException | SaxonApiException e) {
        throw new CatalogGenerationException(e);
    }
}

From source file:com.bluexml.xforms.generator.forms.renderable.common.field.AbstractRenderableField.java

@Override
public Rendered render(String path, Stack<Renderable> parents, Stack<Rendered> renderedParents,
        boolean isInIMultRepeater) {
    attributeId = XFormsGenerator.getId(getOwner() + "_" + getName());

    RenderedXMLElement rendered = new RenderedXMLElement();

    ModelElementBindSimple meb = null;/* w w w .  ja v  a2  s .co m*/
    String xsdType = getXsdType();
    if (xsdType.equals(MsgId.INT_TYPE_XSD_DATETIME.getText())) {
        if (isReadOnly()) {
            meb = new ModelElementBindSimple(path);
            // meb.setType(new QName("string"));
        } else {
            meb = new ModelElementBindSimple(path + "/date");
            meb.setType(new QName(MsgId.INT_TYPE_XSD_DATE.getText()));
            ModelElementBindSimple mebTime = new ModelElementBindSimple(path + "/time");
            mebTime.setType(new QName(MsgId.INT_TYPE_XSD_TIME.getText()));
            meb.setAnotherMeb(mebTime);
            rendered.addModelElement(mebTime);
        }
    } else {
        meb = new ModelElementBindSimple(path);
        applyConstraints(meb);
        if (xsdType.equals("anyType")) {
            meb.setType(new QName("string"));
            // let's hide the anyType objects, since XForms doesn't deal with that
            setHidden(meb, true);
        } else {
            meb.setType(new QName(xsdType));
        }
    }
    rendered.addModelElement(meb);

    String slabel = MsgPool.getMsg(MsgId.MSG_FIELD_LABEL_FORMAT, getTitle());

    Element element = null;
    if (isReadOnly()) {
        meb.setReadOnly(true);
        if (StringUtils.equals(getXsdType(), MsgId.INT_TYPE_XSD_DATE.getText())
                || StringUtils.equals(getXsdType(), MsgId.INT_TYPE_XSD_TIME.getText())
                || StringUtils.equals(getXsdType(), MsgId.INT_TYPE_XSD_DATETIME.getText())) {
            element = getReadOnlyElement(meb, slabel, false); // #1248
        } else {
            element = getCustomElement(rendered, meb, slabel, parents, renderedParents);
        }
    } else {
        element = getCustomElement(rendered, meb, slabel, parents, renderedParents);
    }
    rendered.setXformsElement(element);
    applyStyle(rendered);

    return rendered;
}

From source file:com.msopentech.odatajclient.testservice.utils.AbstractUtilities.java

private void initialize() throws Exception {

    if (!initialized.contains(version)) {
        final MetadataLinkInfo metadataLinkInfo = new MetadataLinkInfo();
        Commons.linkInfo.put(version, metadataLinkInfo);

        final InputStream metadata = fsManager.readFile(Constants.METADATA, Accept.XML);
        final XMLEventReader reader = XMLUtilities.getEventReader(metadata);

        int initialDepth = 0;
        try {/*from  w  ww  .  j  a v a 2  s  .  c o  m*/
            while (true) {
                Map.Entry<Integer, XmlElement> entityType = XMLUtilities.getAtomElement(reader, null,
                        "EntityType", null, initialDepth, 4, 4, false);
                initialDepth = entityType.getKey();

                final String entitySetName = entityType.getValue().getStart()
                        .getAttributeByName(new QName("Name")).getValue();

                final XMLEventReader entityReader = XMLUtilities
                        .getEventReader(entityType.getValue().toStream());
                int size = 0;

                try {
                    while (true) {
                        final XmlElement navProperty = XMLUtilities.getAtomElement(entityReader, null,
                                "NavigationProperty");

                        final String linkName = navProperty.getStart().getAttributeByName(new QName("Name"))
                                .getValue();

                        final Map.Entry<String, Boolean> target = getTargetInfo(navProperty.getStart(),
                                linkName);

                        metadataLinkInfo.addLink(entitySetName, linkName, target.getKey(), target.getValue());

                        size++;
                    }
                } catch (Exception e) {
                } finally {
                    entityReader.close();
                }

                if (size == 0) {
                    metadataLinkInfo.addEntitySet(entitySetName);
                }
            }
        } catch (Exception e) {
        } finally {
            reader.close();
            initialized.add(version);
        }
    }
}

From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.MultimediaWSDaoTest.java

@Override
@Test/*from  w  w  w.  ja va2  s  .  c om*/
public void getSessionRepositoryMultimediasTest() throws Exception {
    when(sasWebServiceOperations.marshalSendAndReceiveToSAS(any(String.class), any(Object.class))).thenReturn(
            new JAXBElement<BlackboardMultimediaResponseCollection>(new QName("http://sas.elluminate.com"),
                    BlackboardMultimediaResponseCollection.class,
                    new BlackboardMultimediaResponseCollection()));
    super.getSessionRepositoryMultimediasTest();
}

From source file:com.netflix.subtitles.ttml.TtmlParagraphResolver.java

private static <T> T deepCopy(T object, Class<T> clazz, String packages) {
    try {/*  w w  w  .j av a2  s. co  m*/
        JAXBContext jaxbContext = JAXBContext.newInstance(packages);

        //  create marshaller which disable validation step
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setEventHandler(event -> true);

        //  create unmarshaller which disable validation step
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        unmarshaller.setEventHandler(event -> true);

        JAXBElement<T> contentObject = new JAXBElement<>(new QName(clazz.getName()), clazz, object);
        return unmarshaller.unmarshal(new JAXBSource(marshaller, contentObject), clazz).getValue();
    } catch (JAXBException e) {
        throw new ParseException("Time overlaps in <p> cannot be resolved.", e);
    }
}

From source file:com.hazelcast.simulator.probes.probes.ProbesResultXmlReader.java

private static void parseProbe(XMLEventReader reader, StartElement startElement, Map<String, Result> result)
        throws XMLStreamException {
    String name = startElement.getAttributeByName(new QName(PROBE_NAME.getName())).getValue();
    String type = startElement.getAttributeByName(new QName(PROBE_TYPE.getName())).getValue();

    Result probeResult = null;/*from  www  .  j a  v  a 2s  .  c  om*/
    if (OperationsPerSecResult.XML_TYPE.equals(type)) {
        probeResult = parseOperationsPerSecResult(reader);
    } else if (MaxLatencyResult.XML_TYPE.equals(type)) {
        probeResult = parseMaxLatencyResult(reader);
    } else if (HdrLatencyDistributionResult.XML_TYPE.equals(type)) {
        probeResult = parseHdrLatencyProbeResult(reader);
    } else if (LatencyDistributionResult.XML_TYPE.equals(type)) {
        probeResult = parseLatencyDistributionResult(reader);
    }
    result.put(name, probeResult);
}

From source file:com.bluexml.xforms.generator.forms.modelelement.ModelElementBindSimple.java

@Override
public Element getModelElement() {
    String bindId = XFormsGenerator.getId(MsgId.INT_GEN_PREFIX_BIND_FORM.getText());
    Element bindElement = XFormsGenerator.createElement("bind", XFormsGenerator.NAMESPACE_XFORMS);
    bindElement.setAttribute("nodeset", nodeset);
    bindElement.setAttribute("id", bindId);
    if (type != null) {
        // ** #1280
        String typeStr = type.toString();
        if ((typeStr.equalsIgnoreCase(MsgId.INT_TYPE_XSD_DATE.getText())
                || typeStr.equalsIgnoreCase(MsgId.INT_TYPE_XSD_DATETIME.getText())
                || typeStr.equalsIgnoreCase(MsgId.INT_TYPE_XSD_TIME.getText())) && isReadOnly()) {
            typeStr = "string";
            // there is not much use in setting the 'type' field, we do it for being consistent.
            type = new QName("string");
        }/*from   w ww  .j a  v a2  s  . c o  m*/
        // ** #1280
        bindElement.setAttribute("type", typeStr);
    }
    if (isRequired()) {
        String ref = getMultipleInputReference();
        if (ref != null) { // this bind is for an input with multiple values 
            //** #1420
            String reqExpr = "instance('minstance')/" + ref + "[1]/";
            reqExpr = reqExpr + MsgId.INT_INSTANCE_INPUT_MULT_VALUE + " eq ''";
            bindElement.setAttribute("required", reqExpr);
            //** #1420
        } else {
            bindElement.setAttribute("required", "true()");
            if (isAnAssociation() == false) {
                setConstraint("(. ne '')");
            }
        }
    } else {
        // if (getLengthConstraint() != null) {
        // bindElement.setAttribute("required", "not (string-length(.) = 0 or ("
        // + getLengthConstraint() + "))");
        // }
    }
    if (isReadOnly()) {
        bindElement.setAttribute("readonly", "true()");
    }
    if (isHidden()) {
        bindElement.setAttribute("relevant", "false()");
    } else {
        // ** #1340
        if (isRequired()) { // TO UPDATE in case regex fields no longer allow empty strings
            setRelevantAttrForGhostTemplate(bindElement);
        }
        // ** #1340
    }
    if (StringUtils.trimToNull(constraint) != null) {
        bindElement.setAttribute("constraint", constraint);
    }

    for (Element linkedElement : linkedElements) {
        linkedElement.setAttribute("bind", bindId);
    }

    return bindElement;
}

From source file:com.marklogic.client.test.KeyValueSearchTest.java

@Test
public void testKVSearchGoodNamespacePrefix() throws IOException {
    QueryManager queryMgr = Common.client.newQueryManager();
    KeyValueQueryDefinition qdef = queryMgr.newKeyValueDefinition(null);

    qdef.put(queryMgr.newElementLocator(new QName("json:thirdKey")), "3");
    SearchHandle results = queryMgr.search(qdef, new SearchHandle());
    assertNotNull(results);/*www  . ja v  a2s.  c o  m*/
    assertFalse(results.getMetrics().getTotalTime() == -1);

    MatchDocumentSummary[] summaries = results.getMatchResults();
    assertNotNull(summaries);
    assertEquals("expected 1 result", 1, summaries.length);
    for (MatchDocumentSummary summary : summaries) {
        MatchLocation[] locations = summary.getMatchLocations();
        assertEquals("expected 1 match location", 1, locations.length);
        for (MatchLocation location : locations) {
            assertNotNull(location.getAllSnippetText());
        }
    }
}

From source file:com.evolveum.midpoint.model.common.expression.functions.CustomFunctions.java

public <V extends PrismValue, D extends ItemDefinition> Object execute(String functionName,
        Map<String, Object> params) throws ExpressionEvaluationException {
    Validate.notNull(functionName, "Function name must be specified");

    List<ExpressionType> functions = library.getFunction().stream()
            .filter(expression -> functionName.equals(expression.getName())).collect(Collectors.toList());

    LOGGER.trace("functions {}", functions);
    ExpressionType expressionType = functions.iterator().next();

    LOGGER.trace("function to execute {}", expressionType);

    try {/*from   w w  w  .  j  a va2s  . c  o m*/
        ExpressionVariables variables = new ExpressionVariables();
        if (MapUtils.isNotEmpty(params)) {
            for (Map.Entry<String, Object> entry : params.entrySet()) {
                variables.addVariableDefinition(new QName(entry.getKey()), convertInput(entry, expressionType));
            }
            ;
        }

        QName returnType = expressionType.getReturnType();
        if (returnType == null) {
            returnType = DOMUtil.XSD_STRING;
        }

        D outputDefinition = (D) prismContext.getSchemaRegistry().findItemDefinitionByType(returnType);
        if (outputDefinition == null) {
            outputDefinition = (D) new PrismPropertyDefinitionImpl(SchemaConstantsGenerated.C_VALUE, returnType,
                    prismContext);
        }
        if (expressionType.getReturnMultiplicity() != null
                && expressionType.getReturnMultiplicity() == ExpressionReturnMultiplicityType.MULTI) {
            outputDefinition.setMaxOccurs(-1);
        } else {
            outputDefinition.setMaxOccurs(1);
        }
        String shortDesc = "custom function execute";
        Expression<V, D> expression = expressionFactory.makeExpression(expressionType, outputDefinition,
                shortDesc, task, result);

        ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, shortDesc, task,
                result);
        PrismValueDeltaSetTriple<V> outputTriple = expression.evaluate(context);

        LOGGER.trace("Result of the expression evaluation: {}", outputTriple);

        if (outputTriple == null) {
            return null;
        }

        Collection<V> nonNegativeValues = outputTriple.getNonNegativeValues();

        if (nonNegativeValues == null || nonNegativeValues.isEmpty()) {
            return null;
        }

        if (outputDefinition.isMultiValue()) {
            return PrismValue.getRealValuesOfCollection(nonNegativeValues);
        }

        if (nonNegativeValues.size() > 1) {
            throw new ExpressionEvaluationException("Expression returned more than one value ("
                    + nonNegativeValues.size() + ") in " + shortDesc);
        }

        return nonNegativeValues.iterator().next().getRealValue();

    } catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException
            | ConfigurationException | SecurityViolationException e) {
        throw new ExpressionEvaluationException(e.getMessage(), e);
    }

}

From source file:net.sf.taverna.t2.activities.soaplab.views.SoaplabActivityContextualView.java

private String getMetadata() {
    try {//www .j  a  v a  2 s  .  co  m
        Configuration configuration = getConfigBean();
        JsonNode json = configuration.getJson();
        String endpoint = json.get("endpoint").textValue();
        Call call = (Call) new Service().createCall();
        call.setTimeout(new Integer(0));
        call.setTargetEndpointAddress(endpoint);
        call.setOperationName(new QName("describe"));
        String metadata = (String) call.invoke(new Object[0]);
        logger.info(metadata);
        // Old impl, returns a tree of the XML
        // ColXMLTree tree = new ColXMLTree(metadata);
        URL sheetURL = SoaplabActivityContextualView.class.getResource("/analysis_metadata_2_html.xsl");
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        logger.info(sheetURL.toString());
        Templates stylesheet = transformerFactory.newTemplates(new StreamSource(sheetURL.openStream()));
        Transformer transformer = stylesheet.newTransformer();
        StreamSource inputStream = new StreamSource(new ByteArrayInputStream(metadata.getBytes()));
        ByteArrayOutputStream transformedStream = new ByteArrayOutputStream();
        StreamResult result = new StreamResult(transformedStream);
        transformer.transform(inputStream, result);
        transformedStream.flush();
        transformedStream.close();
        // String summaryText = "<html><head>"
        // + WorkflowSummaryAsHTML.STYLE_NOBG + "</head>"
        // + transformedStream.toString() + "</html>";
        // JEditorPane metadataPane = new ColJEditorPane("text/html",
        // summaryText);
        // metadataPane.setText(transformedStream.toString());
        // // logger.info(transformedStream.toString());
        // JScrollPane jsp = new JScrollPane(metadataPane,
        // JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
        // JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        // jsp.setPreferredSize(new Dimension(0, 0));
        // jsp.getVerticalScrollBar().setValue(0);
        return transformedStream.toString();
    } catch (Exception ex) {
        return "<font color=\"red\">Error</font><p>An exception occured while trying to fetch Soaplab metadata from the server. The error was :<pre>"
                + ex.getMessage() + "</pre>";

    }
}