org.apache.xerces.xs.XSModel Java Examples

The following examples show how to use org.apache.xerces.xs.XSModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ToXml.java    From iaf with Apache License 2.0 6 votes vote down vote up
public Set<XSElementDeclaration> findElementDeclarationsForName(String namespace, String name) {
	Set<XSElementDeclaration> result=new LinkedHashSet<XSElementDeclaration>();
	if (schemaInformation==null) {
		log.warn("No SchemaInformation specified, cannot find namespaces for ["+namespace+"]:["+name+"]");
		return null;
	}
	for (XSModel model:schemaInformation) {
		XSNamedMap components = model.getComponents(XSConstants.ELEMENT_DECLARATION);
		for (int i=0;i<components.getLength();i++) {
			XSElementDeclaration item=(XSElementDeclaration)components.item(i);
			if ((namespace==null || namespace.equals(item.getNamespace())) && (name==null || name.equals(item.getName()))) {
				if (log.isTraceEnabled()) log.trace("name ["+item.getName()+"] found in namespace ["+item.getNamespace()+"]");
				result.add(item);
			}
		}
	}
	return result;
}
 
Example #2
Source File: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 6 votes vote down vote up
public JsonObject getDefinitions() {
	JsonObjectBuilder definitionsBuilder = Json.createObjectBuilder();
	for (XSModel model:models) {
		XSNamedMap elements = model.getComponents(XSConstants.ELEMENT_DECLARATION);
		for (int i=0; i<elements.getLength(); i++) {
			XSElementDeclaration elementDecl = (XSElementDeclaration)elements.item(i);
			handleElementDeclaration(definitionsBuilder, elementDecl, false, false);
		}
		XSNamedMap types = model.getComponents(XSConstants.TYPE_DEFINITION);
		for (int i=0; i<types.getLength(); i++) {
			XSTypeDefinition typeDefinition = (XSTypeDefinition)types.item(i);
			String typeNamespace = typeDefinition.getNamespace();
			if (typeNamespace==null || !typeDefinition.getNamespace().equals(XML_SCHEMA_NS)) {
				definitionsBuilder.add(typeDefinition.getName(), getDefinition(typeDefinition, false));
			}
		}
	}
	return definitionsBuilder.build();
}
 
Example #3
Source File: DatatypeMappingTest.java    From exificient with MIT License 6 votes vote down vote up
public static Datatype getSimpleDatatypeFor(String schemaAsString,
		String typeName, String typeURI) throws EXIException {
	XSDGrammarsBuilder xsdGB = XSDGrammarsBuilder.newInstance();
	ByteArrayInputStream bais = new ByteArrayInputStream(
			schemaAsString.getBytes());
	xsdGB.loadGrammars(bais);
	xsdGB.toGrammars();

	XSModel xsModel = xsdGB.getXSModel();

	XSTypeDefinition td = xsModel.getTypeDefinition(typeName, typeURI);

	assertTrue("SimpleType expected",
			td.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE);

	Datatype dt = xsdGB.getDatatype((XSSimpleTypeDefinition) td);

	return dt;
}
 
Example #4
Source File: Json2Xml.java    From iaf with Apache License 2.0 6 votes vote down vote up
public static String translate(JsonStructure json, URL schemaURL, boolean compactJsonArrays, String rootElement, boolean strictSyntax, boolean deepSearch, String targetNamespace, Map<String,Object> overrideValues) throws SAXException, IOException {
	ValidatorHandler validatorHandler = getValidatorHandler(schemaURL);
	List<XSModel> schemaInformation = getSchemaInformation(schemaURL);

	// create the validator, setup the chain
	Json2Xml j2x = new Json2Xml(validatorHandler,schemaInformation,compactJsonArrays,rootElement,strictSyntax);
	if (overrideValues!=null) {
		j2x.setOverrideValues(overrideValues);
	}
	if (targetNamespace!=null) {
		//if (DEBUG) System.out.println("setting targetNamespace ["+targetNamespace+"]");
		j2x.setTargetNamespace(targetNamespace);
	}
	j2x.setDeepSearch(deepSearch);

	return j2x.translate(json);
}
 
Example #5
Source File: XSDOutlinePanel.java    From jlibs with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked"})
public void setXSModel(XSModel model, MyNamespaceSupport nsSupport){
    Navigator navigator1 = new FilteredTreeNavigator(new XSNavigator(), new XSDisplayFilter());
    Navigator navigator = new PathNavigator(navigator1);
    XSPathDiplayFilter filter = new XSPathDiplayFilter(navigator1);
    navigator = new FilteredTreeNavigator(navigator, filter);
    
    TreeModel treeModel = new NavigatorTreeModel(new Path(model), navigator);
    RowModel rowModel = new DefaultRowModel(new DefaultColumn("Detail", String.class, new XSDisplayValueVisitor(nsSupport))/*, new ClassColumn()*/);

    outline.setModel(DefaultOutlineModel.createOutlineModel(treeModel, rowModel));
    outline.getColumnModel().getColumn(1).setMinWidth(150);

    DefaultRenderDataProvider dataProvider = new DefaultRenderDataProvider();
    dataProvider.setDisplayNameVisitor(new XSDisplayNameVisitor(nsSupport, filter));
    dataProvider.setForegroundVisitor(new XSColorVisitor(filter));
    dataProvider.setFontStyleVisitor(new XSFontStyleVisitor(filter));
    outline.setRenderDataProvider(dataProvider);
}
 
Example #6
Source File: CMXSDDocument.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create files tracker to track all XML Schema (root and imported) from the XS
 * model.
 * 
 * @return a files tracker to track all XML Schema (root and imported) from the
 *         XS model.
 */
private static FilesChangedTracker createFilesChangedTracker(XSModel model) {
	Set<SchemaGrammar> grammars = new HashSet<>();
	XSNamespaceItemList namespaces = model.getNamespaceItems();
	for (int i = 0; i < namespaces.getLength(); i++) {
		SchemaGrammar grammar = getSchemaGrammar(namespaces.item(i));
		if (grammar != null) {
			grammars.add(grammar);
		}
	}
	return XSDUtils.createFilesChangedTracker(grammars);
}
 
Example #7
Source File: XmlAligner.java    From iaf with Apache License 2.0 5 votes vote down vote up
protected static List<XSModel> getSchemaInformation(URL schemaURL) {
	XMLSchemaLoader xsLoader = new XMLSchemaLoader();
	XSModel xsModel = xsLoader.loadURI(schemaURL.toExternalForm());
	List<XSModel> schemaInformation= new LinkedList<XSModel>();
	schemaInformation.add(xsModel);
	return schemaInformation;
}
 
Example #8
Source File: Properties2Xml.java    From iaf with Apache License 2.0 5 votes vote down vote up
public static String translate(Map<String,String> data, URL schemaURL, String rootElement, String targetNamespace) throws SAXException, IOException {
ValidatorHandler validatorHandler = getValidatorHandler(schemaURL);
List<XSModel> schemaInformation = getSchemaInformation(schemaURL);

// create the validator, setup the chain
Properties2Xml p2x = new Properties2Xml(validatorHandler,schemaInformation,rootElement);
if (targetNamespace!=null) {
	p2x.setTargetNamespace(targetNamespace);
}

return p2x.translate(data);
}
 
Example #9
Source File: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 5 votes vote down vote up
public JsonStructure createJsonSchema(String elementName, String namespace) {
	XSElementDeclaration elementDecl=findElementDeclaration(elementName, namespace);
	if (elementDecl==null && namespace!=null) {
		elementDecl=findElementDeclaration(elementName, null);
	}
	if (elementDecl==null) {
		log.warn("Cannot find declaration for element ["+elementName+"]");
		if (log.isTraceEnabled()) 
			for (XSModel model:models) {
				log.trace("model ["+ToStringBuilder.reflectionToString(model,ToStringStyle.MULTI_LINE_STYLE)+"]");
			}
		return null;
	}
	return createJsonSchema(elementName, elementDecl);
}
 
Example #10
Source File: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 5 votes vote down vote up
public XmlTypeToJsonSchemaConverter(List<XSModel> models, boolean skipArrayElementContainers, boolean skipRootElement, String schemaLocation, String definitionsPath) {
	this.models=models;
	this.skipArrayElementContainers=skipArrayElementContainers;
	this.skipRootElement=skipRootElement;
	this.schemaLocation=schemaLocation;
	this.definitionsPath=definitionsPath;
}
 
Example #11
Source File: DomTreeAligner.java    From iaf with Apache License 2.0 5 votes vote down vote up
public static String translate(Document xmlIn, URL schemaURL) throws SAXException, IOException {
ValidatorHandler validatorHandler = getValidatorHandler(schemaURL);
List<XSModel> schemaInformation = getSchemaInformation(schemaURL);

// create the validator, setup the chain
DomTreeAligner dta = new DomTreeAligner(validatorHandler,schemaInformation);

return dta.translate(xmlIn);
}
 
Example #12
Source File: XercesXmlValidator.java    From iaf with Apache License 2.0 5 votes vote down vote up
public List<XSModel> getXsModels() {
	if (xsModels==null) {
		xsModels=new LinkedList<XSModel>();
		Grammar[] grammars=grammarPool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
		for(int i=0;i<grammars.length;i++) {
			xsModels.add(((XSGrammar)grammars[i]).toXSModel());
		}
	}
	return xsModels;
}
 
Example #13
Source File: JavaxXmlValidator.java    From iaf with Apache License 2.0 5 votes vote down vote up
JavaxValidationContext(String schemasId, Schema schema, Set<String> namespaceSet, List<XSModel> xsModels) {
	super();
	this.schemasId=schemasId;
	this.schema=schema;
	this.namespaceSet=namespaceSet;
	this.xsModels=xsModels;
}
 
Example #14
Source File: JavaxXmlValidator.java    From iaf with Apache License 2.0 5 votes vote down vote up
protected List<XSModel> getXSModels(List<nl.nn.adapterframework.validation.Schema> schemas) throws IOException, XMLStreamException, ConfigurationException {
	List<XSModel> result = new ArrayList<XSModel>();
	XMLSchemaLoader xsLoader = new XMLSchemaLoader();
	for (nl.nn.adapterframework.validation.Schema schema : schemas) {
		XSModel xsModel = xsLoader.loadURI(schema.getSystemId());
		result.add(xsModel);
	}
	return result;
}
 
Example #15
Source File: JavaxXmlValidator.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public JavaxValidationContext createValidationContext(IPipeLineSession session, Set<List<String>> rootValidations, Map<List<String>, List<String>> invalidRootNamespaces) throws ConfigurationException, PipeRunException {
	// clear session variables
	super.createValidationContext(session, rootValidations, invalidRootNamespaces);

	String schemasId;
	Schema schema;
	Set<String> namespaceSet=new HashSet<String>();
	List<XSModel> xsModels=null;

	init();
	schemasId = schemasProvider.getSchemasId();
	if (schemasId == null) {
		schemasId = schemasProvider.getSchemasId(session);
		getSchemaObject(schemasId, schemasProvider.getSchemas(session));
	}
	schema = javaxSchemas.get(schemasId);

	if (schema!=null) {
		org.apache.xerces.jaxp.validation.XSGrammarPoolContainer xercesSchema = (org.apache.xerces.jaxp.validation.XSGrammarPoolContainer)schema;
		xercesSchema.getGrammarPool();

		xsModels=new LinkedList<XSModel>();
		Grammar[] grammars=xercesSchema.getGrammarPool().retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
		for(int i=0;i<grammars.length;i++) {
			XSModel model=((XSGrammar)grammars[i]).toXSModel();
			xsModels.add(model);
			StringList namespaces=model.getNamespaces();
			for (int j=0;j<namespaces.getLength();j++) {
				String namespace=namespaces.item(j);
				namespaceSet.add(namespace);
			}
		}
	}

	JavaxValidationContext result= new JavaxValidationContext(schemasId, schema, namespaceSet, xsModels);
	result.init(schemasProvider, schemasId, namespaceSet, rootValidations, invalidRootNamespaces, ignoreUnknownNamespaces);
	return result;
}
 
Example #16
Source File: Path.java    From jlibs with Apache License 2.0 5 votes vote down vote up
public XSModel getSchema(){
    Path path = this;
    while(path!=null){
        if(path.schema!=null)
            return path.schema;
        path = path.parent;
    }
    return null;
}
 
Example #17
Source File: CMXSDContentModelProvider.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public CMDocument createCMDocument(String key) {
	XSLoaderImpl loader = getLoader();
	XSModel model = loader.loadURI(key);
	if (model != null) {
		// XML Schema can be loaded
		return new CMXSDDocument(model, loader);
	}
	return null;
}
 
Example #18
Source File: OutlineNavigatorTest.java    From jlibs with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked"})
public static void main(String[] args) throws Exception{
    String url = JOptionPane.showInputDialog("File/URL", "http://schemas.xmlsoap.org/wsdl/");
    if(url==null)
        return;
    XSModel model = new XSParser().parse(url);
    MyNamespaceSupport nsSupport = XSUtil.createNamespaceSupport(model);

    Navigator navigator1 = new FilteredTreeNavigator(new XSNavigator(), new XSDisplayFilter());
    Navigator navigator = new PathNavigator(navigator1);
    XSPathDiplayFilter filter = new XSPathDiplayFilter(navigator1);
    navigator = new FilteredTreeNavigator(navigator, filter);
    TreeModel treeModel = new NavigatorTreeModel(new Path(model), navigator);
    RowModel rowModel = new DefaultRowModel(new DefaultColumn("Detail", String.class, new XSDisplayValueVisitor(nsSupport))/*, new ClassColumn()*/);
    
    OutlineNavigatorTest test = new OutlineNavigatorTest("Navigator Test");
    Outline outline = test.getOutline();
    outline.setShowGrid(false);
    outline.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
    outline.setModel(DefaultOutlineModel.createOutlineModel(treeModel, rowModel));
    outline.getColumnModel().getColumn(1).setMinWidth(150);

    DefaultRenderDataProvider dataProvider = new DefaultRenderDataProvider();
    dataProvider.setDisplayNameVisitor(new XSDisplayNameVisitor(nsSupport, filter));
    dataProvider.setForegroundVisitor(new XSColorVisitor(filter));
    dataProvider.setFontStyleVisitor(new XSFontStyleVisitor(filter));
    outline.setRenderDataProvider(dataProvider);
    
    test.setVisible(true);
}
 
Example #19
Source File: ParallelTest.java    From exificient with MIT License 5 votes vote down vote up
public void testParallelXerces() throws XNIException, IOException,
		InterruptedException, ExecutionException {

	Collection<Callable<XSModel>> tasks = new ArrayList<Callable<XSModel>>();
	for (int i = 0; i < 25; i++) {
		Callable<XSModel> task = new Callable<XSModel>() {
			public XSModel call() throws Exception {
				XMLEntityResolver entityResolver = new TestXSDResolver();
				String sXSD = "./data/XSLT/schema-for-xslt20.xsd";
				// load XSD schema & get XSModel
				XMLSchemaLoader sl = new XMLSchemaLoader();
				sl.setEntityResolver(entityResolver);
				XMLInputSource xsdSource = new XMLInputSource(null, sXSD,
						null);

				SchemaGrammar g = (SchemaGrammar) sl.loadGrammar(xsdSource);
				XSModel xsModel = g.toXSModel();
				return xsModel;
			}
		};

		tasks.add(task);
	}

	ExecutorService executor = Executors.newFixedThreadPool(4);
	List<Future<XSModel>> results = executor.invokeAll(tasks);

	for (Future<XSModel> result : results) {
		System.out.println("XSModel: " + result.get());
	}
}
 
Example #20
Source File: SentinelXsdDumpMetadata.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args)
{
   if (!args[0].equals("--dump"))
   {
      // Activates the resolver for Drb
      try
      {
         DrbFactoryResolver.setMetadataResolver (
               new DrbCortexMetadataResolver (
            DrbCortexModel.getDefaultModel ()));
      }
      catch (IOException e)
      {
         System.err.println ("Resolver cannot be handled.");
      }
      process(args[0]);
   }
   else
   {
   System.out.println("declare function local:deduplicate($list) {");
   System.out.println("  if (fn:empty($list)) then ()");
   System.out.println("  else");
   System.out.println("    let $head := $list[1],");
   System.out.println("      $tail := $list[position() > 1]");
   System.out.println("    return");
   System.out
         .println("      if (fn:exists($tail[ . = $head ])) then " +
               "local:deduplicate($tail)");
   System.out.println("      else ($head, local:deduplicate($tail))");
   System.out.println("};");
   System.out.println();
   System.out.println("declare function local:values($list) {");
   System.out
         .println("  fn:string-join(local:deduplicate(" +
               "fn:data($list)), ' ')");
   System.out.println("};");
   System.out.println();

   System.out.println("let $doc := !!!! GIVE PATH HERE !!!!");
   System.out.println("return\n(\n");

   /**
    * Open XML Schema
    */
   final XSLoader loader = new XMLSchemaLoader();

   final XSModel model = loader.loadURI(args[1]);

   XSNamedMap map = model.getComponents(XSConstants.ELEMENT_DECLARATION);

   if (map != null)
   {
      for (int j = 0; j < map.getLength(); j++)
      {
         dumpElement("", (XSElementDeclaration) map.item(j));
      }
   }

   System.out.println("\n) ^--- REMOVE LAST COMMA !!!");
   }
}
 
Example #21
Source File: Map2Xml.java    From iaf with Apache License 2.0 4 votes vote down vote up
public Map2Xml(ValidatorHandler validatorHandler, List<XSModel> schemaInformation) {
	super(validatorHandler,schemaInformation);
}
 
Example #22
Source File: Json2Xml.java    From iaf with Apache License 2.0 4 votes vote down vote up
public Json2Xml(ValidatorHandler validatorHandler, List<XSModel> schemaInformation, boolean insertElementContainerElements, String rootElement) {
	this(validatorHandler, schemaInformation, insertElementContainerElements, rootElement, false);
}
 
Example #23
Source File: Json2Xml.java    From iaf with Apache License 2.0 4 votes vote down vote up
public Json2Xml(ValidatorHandler validatorHandler, List<XSModel> schemaInformation, boolean insertElementContainerElements, String rootElement, boolean strictSyntax) {
	super(validatorHandler, schemaInformation);
	this.insertElementContainerElements=insertElementContainerElements;
	this.strictSyntax=strictSyntax;
	setRootElement(rootElement);
}
 
Example #24
Source File: Import.java    From jlibs with Apache License 2.0 4 votes vote down vote up
private void importWADL(String systemID) throws Exception{
    Application application = new WADLReader().read(systemID);

    DOMLSInputList inputList = new DOMLSInputList();
    XSModel schema = null;
    if(application.getGrammars()!=null){
        for(Include include: application.getGrammars().getInclude()){
            if(include.getHref()!=null)
                inputList.addSystemID(URLUtil.resolve(systemID, include.getHref()).toString());
        }
        for(Object any: application.getGrammars().getAny()){
            if(any instanceof Element)
                inputList.addStringData(DOMUtil.toString((Element)any), systemID);
        }
    }
    if(!inputList.isEmpty())
        schema = new XSParser().parse(inputList);

    Path root = null;
    for(Resources resources: application.getResources()){
        URI base = URI.create(resources.getBase());
        String url = base.getScheme()+"://"+base.getHost();
        if(base.getPort()!=-1)
            url += ":"+base.getPort();
        root = null;
        for(Path path: terminal.getRoots()){
            if(path.name.equals(url)){
                root = path;
                break;
            }
        }
        if(root==null){
            root = new Path(null, url);
            terminal.getRoots().add(root);
            if(base.getPath()!=null && !base.getPath().isEmpty())
                root = root.add(base.getPath());
        }
        root.schema = schema;
        for(Resource resource: resources.getResource())
            importResource(resource, root);
    }
    terminal.setCurrentPath(root);
}
 
Example #25
Source File: Tree2Xml.java    From iaf with Apache License 2.0 4 votes vote down vote up
public Tree2Xml(ValidatorHandler validatorHandler, List<XSModel> schemaInformation) {
	super(validatorHandler,schemaInformation);
}
 
Example #26
Source File: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 4 votes vote down vote up
public XmlTypeToJsonSchemaConverter(List<XSModel> models, boolean skipArrayElementContainers, boolean skipRootElement, String schemaLocation) {
	this(models, skipArrayElementContainers, skipRootElement, schemaLocation, "#/definitions/");
}
 
Example #27
Source File: TestDomTreeAligner.java    From iaf with Apache License 2.0 4 votes vote down vote up
@Override
	public void testFiles(String schemaFile, String namespace, String rootElement, String inputFile, boolean potentialCompactionProblems, String expectedFailureReason) throws Exception {
		URL schemaUrl=getSchemaURL(schemaFile);
    	String xsdUri=schemaUrl.toExternalForm();
    	Schema schema = Utils.getSchemaFromResource(schemaUrl);

    	XMLSchemaLoader xsLoader = new XMLSchemaLoader();
		XSModel xsModel = xsLoader.loadURI(xsdUri);
		List<XSModel> schemaInformation= new LinkedList<XSModel>();
		schemaInformation.add(xsModel);
   	
    	String xmlString=getTestFile(inputFile+".xml");
    	
    	boolean expectValid=expectedFailureReason==null;
    	
    	assertEquals("valid XML", expectValid, Utils.validate(schemaUrl, xmlString));
 	

    	ValidatorHandler validator = schema.newValidatorHandler();
    	DomTreeAligner aligner = new DomTreeAligner(validator, schemaInformation);
 //   	Xml2Json xml2json = new Xml2Json(aligner, false);
    	
    	validator.setContentHandler(aligner);
//    	aligner.setContentHandler(xml2json);
 
    	Document domIn = Utils.string2Dom(xmlString);
    	System.out.println("input DOM ["+Utils.dom2String1(domIn)+"]");
//    	System.out.println("xmlString "+xmlString);
//    	System.out.println("dom in "+ToStringBuilder.reflectionToString(domIn.getDocumentElement()));
    	Source source=aligner.asSource(domIn);
    	System.out.println();
    	System.out.println("start aligning "+inputFile);
   	
		
    	String xmlAct = Utils.source2String(source);
    	System.out.println("xml aligned via source="+xmlAct);
    	assertNotNull("xmlAct is null",xmlAct);
    	assertTrue("XML is not aligned",  Utils.validate(schemaUrl, xmlAct));

//    	InputSource is = new InputSource(new StringReader(xmlString));
//    	try {
// //       	String jsonOut=xml2json.toString();
//        	System.out.println("jsonOut="+jsonOut);
//        	if (!expectValid) {
//    			fail("expected to fail");
//    		}
//    	} catch (Exception e) {
//    		if (expectValid) {
//    			e.printStackTrace();
//    			fail(e.getMessage());
//    		}
//    	}
//    	String xmlString=getTestXml(xml);
//    	String xsdUri=Utils.class.getResource(xsd).toExternalForm();
//    	
//    	assertEquals("valid XML", expectValid, Utils.validate(namespace, xsdUri, xmlString));
//    	
//    	Document dom = Utils.string2Dom(xmlString);
//    	Utils.clean(dom);
//    	
//    	XMLReader parser = new SAXParser();
//    	Schema schema=Utils.getSchemaFromResource(namespace, xsdUri);
//    	ValidatorHandler validator = schema.newValidatorHandler();
//    	XmlAligner instance = implementation.newInstance();
//    	instance.setPsviProvider((PSVIProvider)validator);
//    	
//    	parser.setContentHandler(validator);
//    	validator.setContentHandler(instance);
//    	
//    	System.out.println();
//    	System.out.println("start aligning "+xml);

//    	instance.parse(dom.getDocumentElement());
//    	System.out.println("alignedXml="+Utils.dom2String1(dom));
//    	assertTrue("valid aligned XML", Utils.validate(namespace, xsdUri, dom)); // only if dom  itself is modified...

//    	testXmlAligner(instance, dom.getDocumentElement(), namespace, xsdUri);

//    	JSONObject json=Utils.xml2Json(xmlString);
//    	System.out.println("JSON:"+json);
//    	String jsonString = json.toString();
//    	
//    	jsonString=jsonString.replaceAll(",\"xmlns\":\"[^\"]*\"", "");
//    	System.out.println("JSON with fixed xmlns:"+jsonString);
//    	
//    	String xmlFromJson = Utils.json2Xml(Utils.string2Json(jsonString));
//    	if (StringUtils.isNotEmpty(namespace)) {
//    		xmlFromJson=xmlFromJson.replaceFirst(">", " xmlns=\""+namespace+"\">");
//    	}
//    	System.out.println("start aligning xml from json "+xmlFromJson);
//    	Document domFromJson = Utils.string2Dom(xmlFromJson);
//    	instance.startParse(domFromJson.getDocumentElement());
    	
    }
 
Example #28
Source File: Properties2Xml.java    From iaf with Apache License 2.0 4 votes vote down vote up
public Properties2Xml(ValidatorHandler validatorHandler, List<XSModel> schemaInformation, String rootElement) {
	super(validatorHandler, schemaInformation);
	setRootElement(rootElement);
}
 
Example #29
Source File: XMLToJSON.java    From ts-reaktive with MIT License 4 votes vote down vote up
public XMLToJSON(XSModel model) {
    this.model = model;
}
 
Example #30
Source File: ToXml.java    From iaf with Apache License 2.0 4 votes vote down vote up
public ToXml(ValidatorHandler validatorHandler, List<XSModel> schemaInformation) {
	this(validatorHandler);
	this.schemaInformation=schemaInformation;
}