public ElementInstance element(String text, QName original, String name) { try { File temp = File.createTempFile("name", "xsd"); FileWriter file = new FileWriter(temp); BufferedWriter buff = new BufferedWriter(file); PrintWriter print = new PrintWriter(buff); print.println( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + " <xsd:schema xmlns:my=\"http://mails/refractions/net\"" + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" + " targetNamespace=\"http://localhost//test\">" + " <xsd:element name=\"" + name + "\" type=\"xsd:" + original.getLocalPart() + "\"/>" + "</xsd:schema>"); URL url = temp.toURL(); XSDParser parser = new XSDParser(); parser.parse(url.toString()); XSDSchema schema = parser.getSchema(); Map map = schema.getSimpleTypeIdMap(); return (ElementInstance) map.get(name); } catch (Throwable t) { java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", t); return null; } }
protected void createUserInfo(XSDAnnotation xsdAnnotation, String documentation) { Element userInformation = xsdAnnotation.createUserInformation(null); // Try to parse the documentation and use the parsed version if it's successful. // XSDParser xsdParser = new XSDParser(null); xsdParser.parseString("<documentation>" + documentation + "</documentation>"); Document document = xsdParser.getDocument(); if (xsdParser.getDiagnostics().isEmpty() && document.getDocumentElement().getFirstChild() != null) { Document xsdDocument = xsdAnnotation.getSchema().getDocument(); for (Node node = document.getDocumentElement().getFirstChild(); node != null; node = node.getNextSibling()) { userInformation.appendChild(xsdDocument.importNode(node, true)); } } else { userInformation.appendChild(xsdAnnotation.getSchema().getDocument().createTextNode(documentation)); } xsdAnnotation.getElement().appendChild(userInformation); }
protected void createUserInfo(XSDAnnotation xsdAnnotation, String documentation) { Element userInformation = xsdAnnotation.createUserInformation(null); // Try to parse the documentation and use the parsed version if it's successful. // XSDParser xsdParser = new XSDParser(null); xsdParser.parseString("<documentation>" + documentation + "</documentation>"); Document document = xsdParser.getDocument(); if (xsdParser.getDiagnostics().isEmpty() && document.getDocumentElement().getFirstChild() != null) { Document xsdDocument = xsdAnnotation.getSchema().getDocument(); for (Node node = document.getDocumentElement().getFirstChild(); node != null; node = node.getNextSibling()) { userInformation.appendChild(xsdDocument.importNode(node, true)); } } else { userInformation.appendChild(xsdAnnotation.getSchema().getDocument().createTextNode(documentation)); } xsdAnnotation.getElement().appendChild(userInformation); }
xsdParser = new XSDParser(null);
xsdParser = new XSDParser(null);
XSDParser xsdParser = new XSDParser(options); xsdParser.parse(inputSource); document = xsdParser.getDocument();
monitor.worked(50); XSDParser parser = new XSDParser(); parser.parse(xsdModelFile);
XSDParser xsdParser = new XSDParser(options); xsdParser.parse(inputSource); document = xsdParser.getDocument();
final String normalizedXSDFile = URIHelper.normalize(xsdFile, currentIFile.getLocation().toString(), ""); //$NON-NLS-1$ XSDParser parser = new XSDParser(); parser.parse(normalizedXSDFile);