-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ccd125
commit b0389c6
Showing
11 changed files
with
5,949 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
build/ | ||
.out/ | ||
bin/ | ||
.bin/ | ||
target/ | ||
|
||
/gradle.properties | ||
/archive/ | ||
/META-INF | ||
|
||
.classpath | ||
.project | ||
.settings | ||
|
||
.idea/ | ||
*.iml | ||
*.iws | ||
*.ipr | ||
.idea_modules/ | ||
**/out/ | ||
|
||
*.tmp | ||
*.bak | ||
*.swp | ||
*~ | ||
|
||
.gradle | ||
|
||
.DS_Store* | ||
.AppleDouble | ||
.LSOverride | ||
|
||
.directory | ||
.Trash* | ||
|
||
**/adhoctest/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse</groupId> | ||
<artifactId>lsp4xml-extensions</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>org.eclipse.lsp4xml.xsl</artifactId> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.7</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.lsp4j</groupId> | ||
<artifactId>org.eclipse.lsp4j</artifactId> | ||
<version>${lsp4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.lsp4j</groupId> | ||
<artifactId>org.eclipse.lsp4j.jsonrpc</artifactId> | ||
<version>${lsp4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.xtext</groupId> | ||
<artifactId>org.eclipse.xtext.xbase.lib</artifactId> | ||
<version>2.14.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse</groupId> | ||
<artifactId>org.eclipse.lsp4xml</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
1 change: 1 addition & 0 deletions
1
...xsl/src/main/java/META-INF/services/org.eclipse.lsp4xml.services.extensions.IXMLExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.eclipse.lsp4xml.xsl.XSLPlugin |
29 changes: 29 additions & 0 deletions
29
extensions/org.eclipse.lsp4xml.xsl/src/main/java/org/eclipse/lsp4xml/xsl/XSLPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.eclipse.lsp4xml.xsl; | ||
|
||
import org.eclipse.lsp4xml.services.extensions.IXMLExtension; | ||
import org.eclipse.lsp4xml.services.extensions.XMLExtensionsRegistry; | ||
import org.eclipse.lsp4xml.uriresolver.URIResolverExtensionManager; | ||
|
||
public class XSLPlugin implements IXMLExtension { | ||
|
||
private final XSLURIResolverExtension uiResolver; | ||
|
||
public XSLPlugin() { | ||
uiResolver = new XSLURIResolverExtension(); | ||
} | ||
|
||
@Override | ||
public void updateSettings(Object settings) { | ||
|
||
} | ||
|
||
@Override | ||
public void start(XMLExtensionsRegistry registry) { | ||
URIResolverExtensionManager.getInstance().registerResolver(uiResolver); | ||
} | ||
|
||
@Override | ||
public void stop(XMLExtensionsRegistry registry) { | ||
URIResolverExtensionManager.getInstance().unregisterResolver(uiResolver); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...rg.eclipse.lsp4xml.xsl/src/main/java/org/eclipse/lsp4xml/xsl/XSLURIResolverExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.eclipse.lsp4xml.xsl; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.Writer; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import org.eclipse.lsp4xml.uriresolver.URIResolverExtension; | ||
|
||
public class XSLURIResolverExtension implements URIResolverExtension { | ||
|
||
/** | ||
* The XSL namespace URI (= http://www.w3.org/1999/XSL/Transform) | ||
*/ | ||
private static final String XSL_NAMESPACE_URI = "http://www.w3.org/1999/XSL/Transform"; //$NON-NLS-1$ | ||
|
||
@Override | ||
public String resolve(String baseLocation, String publicId, String systemId) { | ||
if (!XSL_NAMESPACE_URI.equals(publicId)) { | ||
return null; | ||
} | ||
else { | ||
|
||
} | ||
// TODO: extract version from XML Document | ||
String version = "1.0"; | ||
String schemaFileName = "xslt-" + version + ".xsd"; | ||
String schemaPath = "/xslt-schemas/" + schemaFileName; | ||
|
||
try { | ||
Path baseDir = Paths.get("C://lsp4xml"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
angelozerr
Author
Contributor
|
||
Files.createDirectories(baseDir); | ||
Path outFile = baseDir.resolve(schemaFileName); | ||
if (!outFile.toFile().exists()) { | ||
InputStream in = XSLURIResolverExtension.class.getResourceAsStream(schemaPath); | ||
String xml = convertStreamToString(in); | ||
saveToFile(xml, outFile); | ||
} | ||
return outFile.toFile().toURI().toString(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
|
||
private static void saveToFile(String xml, Path outFile) throws IOException { | ||
try (Writer writer = Files.newBufferedWriter(outFile, StandardCharsets.UTF_8)) { | ||
writer.write(xml); | ||
} | ||
} | ||
|
||
static String convertStreamToString(java.io.InputStream is) { | ||
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A"); | ||
return s.hasNext() ? s.next() : ""; | ||
} | ||
|
||
} |
Oops, something went wrong.
nononono