XSD에서 gml (3.1.1) XSD를 사용하고 있습니다. 예를 들어, zip 파일에서 모든 gml XSD를 버전 3.1.1에서 다운로드하려고합니다. 다른 말로하면 : 기본 xsd는 here이고 모든 가져 오기를 Zip 파일이나 Zip 파일과 같이 사용하여이 XSD를 다운로드하려고합니다. 그걸 지원하는 응용 프로그램이 있습니까? 이 내용은 downloader이지만 작동하지 않습니다.이 응용 프로그램은 gml.xsd 3.1.1에서 발생하는 가져 오기에서 상대 경로를 지원하지 않는다고 생각합니다. 어떤 아이디어?모든 가져 오기가 포함 된 XSD 다운로드
답변
QTAssistant 님의 XSR은 모든 종류의 소스에서 로컬 파일로 XSD 콘텐츠를 자동으로 가져오고 리팩토링 할 수있는 사용하기 쉬운 기능을 제공합니다. 이 과정에서 스키마 위치 참조 등을 업데이트 할 것입니다.
이처럼 유용성을 보여줄 수있는 이와 같은 작업을 수행하는 데 필요한 단계는 간단합니다. screen capture.
정말 좋습니다! 감사합니다;) –
나는 일을 수행하는 간단한 자바 주를 쓰고 상대 URL의
package dl;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class SchemaPersister {
private static final String EXPORT_FILESYSTEM_ROOT = "C:/export/xsd";
// some caching of the http-responses
private static Map<String,String> _httpContentCache = new HashMap<String,String>();
public static void main(String[] args) {
try {
new SchemaPersister().doIt();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void doIt() throws Exception {
// // if you need an inouse-Proxy
// final String authUser = "xxxxx";
// final String authPassword = "xxxx"
//
// System.setProperty("http.proxyHost", "xxxxx");
// System.setProperty("http.proxyPort", "xxxx");
// System.setProperty("http.proxyUser", authUser);
// System.setProperty("http.proxyPassword", authPassword);
//
// Authenticator.setDefault(
// new Authenticator() {
// public PasswordAuthentication getPasswordAuthentication() {
// return new PasswordAuthentication(authUser, authPassword.toCharArray());
// }
// }
// );
//
Set <SchemaElement> allElements = new HashSet<SchemaElement>() ;
// URL url = new URL("file:/C:/xauslaender-nachrichten-administration.xsd");
URL url = new URL("http://www.osci.de/xauslaender141/xauslaender-nachrichten-bamf-abh.xsd");
allElements.add (new SchemaElement(url));
for (SchemaElement e: allElements) {
System.out.println("processing " + e);
e.doAll();
}
System.out.println("done!");
}
class SchemaElement {
private URL _url;
private String _content;
public List <SchemaElement> _imports ;
public List <SchemaElement> _includes ;
public SchemaElement(URL url) {
this._url = url;
}
public void checkIncludesAndImportsRecursive() throws Exception {
InputStream in = new ByteArrayInputStream(downloadContent() .getBytes("UTF-8"));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(in);
List<Node> includeNodeList = null;
List<Node> importNodeList = null;
includeNodeList = getXpathAttribute(doc,"/*[local-name()='schema']/*[local-name()='include']");
_includes = new ArrayList <SchemaElement>();
for (Node element: includeNodeList) {
Node sl = element.getAttributes().getNamedItem("schemaLocation");
if (sl == null) {
System.out.println(_url + " defines one import but no schemaLocation");
continue;
}
String asStringAttribute = sl.getNodeValue();
URL url = buildUrl(asStringAttribute,_url);
SchemaElement tmp = new SchemaElement(url);
tmp.setSchemaLocation(asStringAttribute);
tmp.checkIncludesAndImportsRecursive();
_includes.add(tmp);
}
importNodeList = getXpathAttribute(doc,"/*[local-name()='schema']/*[local-name()='import']");
_imports = new ArrayList <SchemaElement>();
for (Node element: importNodeList) {
Node sl = element.getAttributes().getNamedItem("schemaLocation");
if (sl == null) {
System.out.println(_url + " defines one import but no schemaLocation");
continue;
}
String asStringAttribute = sl.getNodeValue();
URL url = buildUrl(asStringAttribute,_url);
SchemaElement tmp = new SchemaElement(url);
tmp.setSchemaLocation(asStringAttribute);
tmp.checkIncludesAndImportsRecursive();
_imports.add(tmp);
}
in.close();
}
private String schemaLocation;
private void setSchemaLocation(String schemaLocation) {
this.schemaLocation = schemaLocation;
}
// http://stackoverflow.com/questions/10159186/how-to-get-parent-url-in-java
private URL buildUrl(String asStringAttribute, URL parent) throws Exception {
if (asStringAttribute.startsWith("http")) {
return new URL(asStringAttribute);
}
if (asStringAttribute.startsWith("file")) {
return new URL(asStringAttribute);
}
// relative URL
URI parentUri = parent.toURI().getPath().endsWith("/") ? parent.toURI().resolve("..") : parent.toURI().resolve(".");
return new URL(parentUri.toURL().toString() + asStringAttribute);
}
public void doAll() throws Exception {
System.out.println("READ ELEMENTS");
checkIncludesAndImportsRecursive();
System.out.println("PRINTING DEPENDENCYS");
printRecursive(0);
System.out.println("GENERATE OUTPUT");
patchAndPersistRecursive(0);
}
public void patchAndPersistRecursive(int level) throws Exception {
File f = new File(EXPORT_FILESYSTEM_ROOT + File.separator + this.getXDSName() );
System.out.println("FILENAME: " + f.getAbsolutePath());
if (_imports.size() > 0) {
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println("IMPORTS");
for (SchemaElement kid : _imports) {
kid.patchAndPersistRecursive(level+1);
}
}
if (_includes.size() > 0) {
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println("INCLUDES");
for (SchemaElement kid : _includes) {
kid.patchAndPersistRecursive(level+1);
}
}
String contentTemp = downloadContent();
for (SchemaElement i : _imports) {
if (i.isHTTP()) {
contentTemp = contentTemp.replace(
"<xs:import schemaLocation=\"" + i.getSchemaLocation() ,
"<xs:import schemaLocation=\"" + i.getXDSName());
}
}
for (SchemaElement i : _includes) {
if (i.isHTTP()) {
contentTemp = contentTemp.replace(
"<xs:include schemaLocation=\"" + i.getSchemaLocation(),
"<xs:include schemaLocation=\"" + i.getXDSName());
}
}
FileOutputStream fos = new FileOutputStream(f);
fos.write(contentTemp.getBytes("UTF-8"));
fos.close();
System.out.println("File written: " + f.getAbsolutePath());
}
public void printRecursive(int level) {
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println(_url.toString());
if (this._imports.size() > 0) {
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println("IMPORTS");
for (SchemaElement kid : this._imports) {
kid.printRecursive(level+1);
}
}
if (this._includes.size() > 0) {
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println("INCLUDES");
for (SchemaElement kid : this._includes) {
kid.printRecursive(level+1);
}
}
}
String getSchemaLocation() {
return schemaLocation;
}
/**
* removes html:// and replaces/with _
* @return
*/
private String getXDSName() {
String tmp = schemaLocation;
// Root on local File-System -- just grap the last part of it
if (tmp == null) {
tmp = _url.toString().replaceFirst(".*/([^/?]+).*", "$1");
}
if (isHTTP()) {
tmp = tmp.replace("http://", "");
tmp = tmp.replace("/", "_");
} else {
tmp = tmp.replace("/", "_");
tmp = tmp.replace("\\", "_");
}
return tmp;
}
private boolean isHTTP() {
return _url.getProtocol().startsWith("http");
}
private String downloadContent() throws Exception {
if (_content == null) {
System.out.println("reading content from " + _url.toString());
if (_httpContentCache.containsKey(_url.toString())) {
this._content = _httpContentCache.get(_url.toString());
System.out.println("Cache hit! " + _url.toString());
} else {
System.out.println("Download " + _url.toString());
Scanner scan = new Scanner(_url.openStream(), "UTF-8");
if (isHTTP()) {
this._content = scan.useDelimiter("\\A").next();
} else {
this._content = scan.useDelimiter("\\Z").next();
}
scan.close();
if (this._content != null) {
_httpContentCache.put(_url.toString(), this._content);
}
}
}
if (_content == null) {
throw new NullPointerException("Content of " + _url.toString() + "is null ");
}
return _content;
}
private List<Node> getXpathAttribute(Document doc, String path) throws Exception {
List <Node> returnList = new ArrayList <Node>();
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
{
XPathExpression expr = xpath.compile(path);
NodeList nodeList = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int i = 0 ; i < nodeList.getLength(); i++) {
Node n = nodeList.item(i);
returnList.add(n);
}
}
return returnList;
}
@Override
public String toString() {
if (_url != null) {
return _url.toString();
}
return super.toString();
}
}
}
공유 주셔서 감사합니다. 좋은 시작이지만이 코드에는 문제가 있습니다. 동일한 xsd 파일이 반복적으로 처리되지 않도록 충분히 검사하지 않습니다. 또한 두 개의 서로 다른 스키마가 동일한 파일 이름을 가진 경우 수행 할 작업을 파악하는 데 어려움이 있습니다. – Ryan
당신이 사용하는 SOAP UI를 달성 할 수로 변경했다.
- 는 WSDL을 사용하여 프로젝트를 만듭니다
다음 단계를 따르십시오.
- 인터페이스를 선택하고 인터페이스 뷰어에서 엽니 다.
- 'WSDL 컨텐츠'탭으로 이동하십시오.
- 'WSDL Content'탭 아래의 마지막 아이콘을 사용하십시오 : '전체 WSDL 및 포함/가져온 파일을 로컬 디렉토리로 내보내기'.
- XSD를 내보낼 폴더를 선택하십시오.
참고 : SOAPUI는 모든 상대 경로를 제거하고 모든 XSD를 같은 폴더에 저장합니다.
mschwehl의 솔루션을 기반으로 가져 오기를 수행하기 위해 향상된 클래스를 만들었습니다. 그것은 질문에 잘 어울립니다. https://github.com/mfalaize/schema-fetcher
잘 작동합니다. 그러나 하나의 누락 된 xsd 파일이 있으면이 소프트웨어가 완전히 중지되므로 모든 HTTP 예외를 포착하고 다시 throw하지 않아야합니다. –
- 1. 데이터 세트로 가져 오기가 포함 된 Embedded XSD로드
- 2. XSD : 복잡한 유형 가져 오기가 작동하지 않습니다.
- 3. EMF에 포함 된 XSD 모델
- 4. XSD 혼란 : 가져 오기 및/또는 포함
- 5. 가져 오기가 작동하지 않습니까?
- 6. 가져 오기가 거북이 서브
- 7. Pylint : 상대 가져 오기가
- 8. WSDL에 포함 된 XSD 파일 경로가 잘못되었습니다.
- 9. XSD minOccurs가 포함 된 유형에 따라 달라집니다.
- 10. 루핑 된 루프 가져 오기 기능에서 모듈 가져 오기가 실행됩니까?
- 11. Django URLconf 포함 : 패키지 가져 오기가 작동하지 않습니다.
- 12. qrcode를 실행하는 데 필요한 가져 오기가 필요합니까?
- 13. 간단한 가져 오기가 실제로 느림
- 14. Magento - 가져 오기가 멈추거나 고정됩니다.
- 15. pymongo가 설치되었지만 가져 오기가 실패합니다.
- 16. 덜 가져 오기가 작동하지 않습니다.
- 17. XSD 런타임 개체 생성
- 18. 갤러리에 포함 된 모든 업로드 이미지를 다운로드하거나 갤러리에 포함 된 모든 업로드 파일을 만듭니다.
- 19. 충돌하는 xsd 가져 오기가있는 wsdl
- 20. svn 가져 오기가 제대로 작동하지 않습니다.
- 21. 변수가 포함 된 PhP 다운로드 링크
- 22. 응용 프로그램의 MEF 컨테이너에서 필드 가져 오기가 포함 된 개체의 연결을 해제하려면 어떻게합니까?
- 23. 재주문 사용하여 가져 오기가 ResultsController
- 24. SciPy 가져 오기가 작동하지 않습니다.
- 25. django.test 가져 오기가 작동하지 않습니다.
- 26. CSS 가져 오기가 연결되지 않았습니다.
- 27. Java 메일 가져 오기가 지연됩니다.
- 28. PostgreSQL을 DB 가져 오기가 잘
- 29. 아약스에서 요소 가져 오기가 실패했습니다.
- 30. draw2d 가져 오기가 해결되지 않았습니다.
내 문제가 해결되었습니다. http://schemas.opengis.net/gml/ :)이 링크는 xsds로 압축되지만 질문은 여전히 실제입니다 ... –