-
Notifications
You must be signed in to change notification settings - Fork 0
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
3e338da
commit c532ffe
Showing
6 changed files
with
68 additions
and
5 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
2 changes: 1 addition & 1 deletion
2
...g/aellen/xml/xsd/MapNamespaceContext.java → ...xml/xsdhierarchy/MapNamespaceContext.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
2 changes: 1 addition & 1 deletion
2
...n/java/org/aellen/xml/xsd/XsdElement.java → .../galinet/xml/xsdhierarchy/XsdElement.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.aellen.xml.xsd; | ||
package ch.galinet.xml.xsdhierarchy; | ||
|
||
/** | ||
* Created by aellenn on 28.04.2017. | ||
|
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,32 @@ | ||
package ch.galinet.xml.xsdhierarchy; | ||
|
||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.jdom.Element; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by aellenn on 04.05.2017. | ||
*/ | ||
public class XsdHelper { | ||
|
||
public static Pair<String, MapNamespaceContext> generateScdPath(Element element) { | ||
List<String> path = new ArrayList<>(); | ||
final MapNamespaceContext ctx = new MapNamespaceContext(); | ||
|
||
while (element.getParent() instanceof Element) { | ||
path.add(0, !element.getNamespacePrefix().equals("") ? element.getNamespacePrefix() + ":" : "" + element.getName()); | ||
ctx.register(element.getNamespacePrefix(), element.getNamespace().getURI()); | ||
element = element.getParentElement(); | ||
} | ||
|
||
final StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < path.size(); i++) { | ||
if (i == 0) sb.append("/"); | ||
sb.append(path.get(i)); | ||
if (i < path.size() - 1) sb.append("//"); | ||
} | ||
return Pair.of(sb.toString(), ctx); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...in/java/org/aellen/xml/xsd/XsdParser.java → ...h/galinet/xml/xsdhierarchy/XsdParser.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
2 changes: 1 addition & 1 deletion
2
...ava/org/aellen/xml/xsd/XsdParserTest.java → ...linet/xml/xsdhierarchy/XsdParserTest.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