Gets the validation context as XML validation context an raises exception if existing validation context is
not a XML validation context.
@return
484559
private XpathMessageValidationContext getXPathValidationContext() {
        if (xmlMessageValidationContext instanceof XpathMessageValidationContext) {
            return ((XpathMessageValidationContext)xmlMessageValidationContext);
        } else {
            XpathMessageValidationContext xPathContext = new XpathMessageValidationContext();
            xPathContext.setNamespaces(xmlMessageValidationContext.getNamespaces());
            xPathContext.setControlNamespaces(xmlMessageValidationContext.getControlNamespaces());
            xPathContext.setIgnoreExpressions(xmlMessageValidationContext.getIgnoreExpressions());
            xPathContext.setSchema(xmlMessageValidationContext.getSchema());
            xPathContext.setSchemaRepository(xmlMessageValidationContext.getSchemaRepository());
            xPathContext.setSchemaValidation(xmlMessageValidationContext.isSchemaValidationEnabled());
            xPathContext.setDTDResource(xmlMessageValidationContext.getDTDResource());

            getAction().getValidationContexts().remove(xmlMessageValidationContext);
            getAction().getValidationContexts().add(xPathContext);

            xmlMessageValidationContext = xPathContext;
            return xPathContext;
        }
    }
141941
@Override
  public String getMessage() {

    if (getValidationExceptions().size() == 0) {
      return super.getMessage();
    }

    StringBuffer sb = new StringBuffer();

    boolean first = true;

    for (Iterator iter = getValidationExceptions().iterator(); iter.hasNext(); ) {
      Exception e = (Exception) iter.next();

      if (!first) {
        sb.append('\n');
        first = false;
      }

      sb.append(e.getMessage());
    }

    return sb.toString();
  }
1157884
public Context getContext() {
		if (context == null) {
			context = Model.getSingleton().getSession().getContext(this.contextId);
		}
		return context;
	}
812036
public boolean getXmlStandalone() {
	// dynamic load to support jre 1.4 and 1.5
	try {
	    Method m = doc.getClass().getMethod("getXmlStandalone", new Class[] {});
	    return Caster.toBooleanValue(m.invoke(doc, ArrayUtil.OBJECT_EMPTY));
	}
	catch (Exception e) {
	    throw new PageRuntimeException(Caster.toPageException(e));
	}
    }
418568
private ScriptValidationContext getScriptValidationContext(Element messageElement, String messageType) {
        ScriptValidationContext context = null;

        boolean done = false;
        List<?> validateElements = DomUtils.getChildElementsByTagName(messageElement, "validate");
        if (validateElements.size() > 0) {
            for (Iterator<?> iter = validateElements.iterator(); iter.hasNext();) {
                Element validateElement = (Element) iter.next();

                Element scriptElement = DomUtils.getChildElementByTagName(validateElement, "script");

                // check for nested validate script child node
                if (scriptElement != null) {
                    if (!done) {
                        done = true;
                    } else {
                        throw new BeanCreationException("Found multiple validation script definitions - " +
                                "only supporting a single validation script for message validation");
                    }

                    context = new ScriptValidationContext(messageType);
                    String type = scriptElement.getAttribute("type");
                    context.setScriptType(type);

                    String filePath = scriptElement.getAttribute("file");
                    if (StringUtils.hasText(filePath)) {
                        context.setValidationScriptResourcePath(filePath);
                        if (scriptElement.hasAttribute("charset")) {
                            context.setValidationScriptResourceCharset(scriptElement.getAttribute("charset"));
                        }
                    } else {
                        context.setValidationScript(DomUtils.getTextValue(scriptElement));
                    }
                }
            }
        }

        return context;
    }
954308
private void validate() {
        if (isValid != null) {
            return;
        }

        ParsingValidator v =
            new ParsingValidator(useSchema ? Languages.W3C_XML_SCHEMA_NS_URI
                                 : Languages.XML_DTD_NS_URI);
        List<Source> schemaSourceList = new ArrayList<Source>();
        if (systemId != null) {
            schemaSourceList.add(new StreamSource(systemId));
        }
        addSchemaSources(schemaSource, schemaSourceList);
        v.setSchemaSources(schemaSourceList.toArray(new Source[0]));

        try {
            ValidationResult r =
                v.validateInstance(new SAXSource(validationInputSource));
            isValid = r.isValid() ? Boolean.TRUE : Boolean.FALSE;
            for (ValidationProblem p : r.getProblems()) {
                validationProblem(p);
            }
        } catch (org.xmlunit.ConfigurationException e) {
            throw new ConfigurationException(e.getCause());
        } catch (org.xmlunit.XMLUnitException e) {
            throw new XMLUnitRuntimeException(e.getMessage(), e.getCause());
        }

        if (usingDoctypeReader && isValid == Boolean.FALSE) {
            try {
                messages.append("\nContent was: ")
                    .append(getOriginalContent(validationInputSource));
            } catch (IOException e) {
                // silent but deadly?
            }
        }
    }
873556
@Override
    public Object getRootContext() throws BadMessageFormatMatchingException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getRootContext");

        // Just call the subclass's method to obtain the DOM Document which
        // represents the payload.
        Object result;
        try {
            result = getPayloadDocument();
        } catch (Exception e) {
            FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.JsApiMessageImpl.getRootContext", "921");
            result = null;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getRootContext", result);
        return result;
    }
1150058
protected ELContext getELContext() {
	FacesContext fc = getFacesContext();
	ELContext result = null;
	if (null != fc) {
	    result = fc.getELContext();
	}
	return result;
    }
99987
@Override
    public XMLValidator createValidator(ValidationContext ctxt)
        throws XMLStreamException
    {
        if (mFullyValidating) {
            return new DTDValidator(this, ctxt, mHasNsDefaults,
                                    getElementMap(), getGeneralEntityMap());
        }
        return new DTDTypingNonValidator(this, ctxt, mHasNsDefaults,
                                         getElementMap(), getGeneralEntityMap());

    }
968275
public String getAsXMLString() {
        // Create a string XML representation:
        String rewardString = null;
        try {
            rewardString = SchemaHelper.serialiseObject(this.getAsReward(), Reward.class);
        } catch (JAXBException e) {
            System.out.println("Caught reward serialization exception: " + e);
        }
        return rewardString;
    }
75840
protected void validateMessageContent(Message receivedMessage, Message controlMessage, XmlMessageValidationContext validationContext,
            TestContext context) {
        if (controlMessage == null || controlMessage.getPayload() == null) {
            log.debug("Skip message payload validation as no control message was defined");
            return;
        }

        if (!(controlMessage.getPayload() instanceof String)) {
            throw new IllegalArgumentException(
                    "DomXmlMessageValidator does only support message payload of type String, " +
                    "but was " + controlMessage.getPayload().getClass());
        }

        String controlMessagePayload = controlMessage.getPayload(String.class);

        if (receivedMessage.getPayload() == null || !StringUtils.hasText(receivedMessage.getPayload(String.class))) {
            Assert.isTrue(!StringUtils.hasText(controlMessagePayload),
                    "Unable to validate message payload - received message payload was empty, control message payload is not");
            return;
        } else if (!StringUtils.hasText(controlMessagePayload)) {
            return;
        }

        log.debug("Start XML tree validation ...");

        Document received = XMLUtils.parseMessagePayload(receivedMessage.getPayload(String.class));
        Document source = XMLUtils.parseMessagePayload(controlMessagePayload);

        XMLUtils.stripWhitespaceNodes(received);
        XMLUtils.stripWhitespaceNodes(source);

        if (log.isDebugEnabled()) {
            log.debug("Received message:\n" + XMLUtils.serialize(received));
            log.debug("Control message:\n" + XMLUtils.serialize(source));
        }

        validateXmlTree(received, source, validationContext, namespaceContextBuilder.buildContext(
                receivedMessage, validationContext.getNamespaces()), context);
    }
629125
public java.util.List<ValidationWarning> getValidationWarnings() {
        if (validationWarnings == null) {
            validationWarnings = new com.amazonaws.internal.SdkInternalList<ValidationWarning>();
        }
        return validationWarnings;
    }
863605
public static DocumentBuilderFactory getStandardDocumentBuilderFactory(boolean validating) {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

        try {
            // enable validation (must specify a grammar)
            dbf.setValidating(validating);
            dbf.setFeature("http://xml.org/sax/features/validation", validating);

            dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", validating);
            dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", validating);

            dbf.setFeature("http://apache.org/xml/features/validation/schema", true);
            dbf.setFeature("http://xml.org/sax/features/namespaces", true);

            dbf.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace", false);
        } catch (ParserConfigurationException pce) {
            throw new RuntimeException("Cannot load standard DocumentBuilderFactory. " + pce.getMessage(), pce);
        }

        dbf.setNamespaceAware(true);
        dbf.setIgnoringComments(true);
        dbf.setExpandEntityReferences(true);

        return dbf;
    }
1191068
@Override
    public ValidationMode getValidationMode()
    {
        // Convert this ValidationMode from the class defined
        // in JAXB (com.ibm.ws.jpa.pxml20.PersistenceUnitValidationModeType)
        // to JPA  (javax.persistence.ValidationMode).

        ValidationMode rtnMode = null;
        PersistenceUnitValidationModeType jaxbMode = null;

        jaxbMode = ivPUnit.getValidationMode();
        if (jaxbMode == PersistenceUnitValidationModeType.AUTO)
        {
            rtnMode = ValidationMode.AUTO;
        }
        else if (jaxbMode == PersistenceUnitValidationModeType.CALLBACK)
        {
            rtnMode = ValidationMode.CALLBACK;
        }
        else if (jaxbMode == PersistenceUnitValidationModeType.NONE)
        {
            rtnMode = ValidationMode.NONE;
        }

        return rtnMode;
    }
458259
protected List<ValidationContext> parseValidationContexts(Element messageElement, BeanDefinitionBuilder builder) {
        List<ValidationContext> validationContexts = new ArrayList<>();
        if (messageElement != null) {
            String messageType = messageElement.getAttribute("type");
            if (!StringUtils.hasText(messageType)) {
                messageType = Citrus.DEFAULT_MESSAGE_TYPE;
            } else {
                builder.addPropertyValue("messageType", messageType);
            }

            HeaderValidationContext headerValidationContext = new HeaderValidationContext();
            validationContexts.add(headerValidationContext);

            String headerValidator = messageElement.getAttribute("header-validator");
            if (StringUtils.hasText(headerValidator)) {
                headerValidationContext.addHeaderValidator(headerValidator);
            }

            String headerValidatorExpression = messageElement.getAttribute("header-validators");
            if (StringUtils.hasText(headerValidatorExpression)) {
                Stream.of(headerValidatorExpression.split(","))
                        .map(String::trim)
                        .forEach(headerValidationContext::addHeaderValidator);
            }

            XmlMessageValidationContext xmlMessageValidationContext = getXmlMessageValidationContext(messageElement);
            validationContexts.add(xmlMessageValidationContext);

            XpathMessageValidationContext xPathMessageValidationContext = getXPathMessageValidationContext(messageElement, xmlMessageValidationContext);
            if (!xPathMessageValidationContext.getXpathExpressions().isEmpty()) {
                validationContexts.add(xPathMessageValidationContext);
            }

            JsonMessageValidationContext jsonMessageValidationContext = getJsonMessageValidationContext(messageElement);
            validationContexts.add(jsonMessageValidationContext);

            JsonPathMessageValidationContext jsonPathMessageValidationContext = getJsonPathMessageValidationContext(messageElement);
            if (!jsonPathMessageValidationContext.getJsonPathExpressions().isEmpty()) {
                validationContexts.add(jsonPathMessageValidationContext);
            }

            ScriptValidationContext scriptValidationContext = getScriptValidationContext(messageElement, messageType);
            if (scriptValidationContext != null) {
                validationContexts.add(scriptValidationContext);
            }

            ManagedList<RuntimeBeanReference> validators = new ManagedList<>();
            String messageValidator = messageElement.getAttribute("validator");
            if (StringUtils.hasText(messageValidator)) {
                validators.add(new RuntimeBeanReference(messageValidator));
            }

            String messageValidatorExpression = messageElement.getAttribute("validators");
            if (StringUtils.hasText(messageValidatorExpression)) {
                Stream.of(messageValidatorExpression.split(","))
                        .map(String::trim)
                        .map(RuntimeBeanReference::new)
                        .forEach(validators::add);
            }

            if (!validators.isEmpty()) {
                builder.addPropertyValue("validators", validators);
            }

            String dataDictionary = messageElement.getAttribute("data-dictionary");
            if (StringUtils.hasText(dataDictionary)) {
                builder.addPropertyReference("dataDictionary", dataDictionary);
            }
        } else {
            validationContexts.add(new HeaderValidationContext());
        }

        return validationContexts;
    }
626277
public static Context getApplicationContext() {
        com.ardikars.jxnet.context.Context context = com.ardikars.jxnet.context.Application.getApplicationContext();
        return new ApplicationContext(context);
    }
1194624
public String getValidationScript(TestContext context) {
        try {
            if (validationScriptResourcePath != null) {
                return context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(validationScriptResourcePath, context),
                        Charset.forName(context.replaceDynamicContentInString(validationScriptResourceCharset))));
            } else if (validationScript != null) {
                return context.replaceDynamicContentInString(validationScript);
            } else {
                return "";
            }
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to load validation script resource", e);
        }
    }