1
1
mirror of https://github.com/dgis/xsddiagram.git synced 2024-09-11 18:47:19 +03:00

Add the namespace in the command line option -r (Thanks Kevin)

This commit is contained in:
dgis 2016-10-21 11:36:45 +02:00
parent f1908a450f
commit 812fbb759f
5 changed files with 44 additions and 16 deletions

View File

@ -186,14 +186,27 @@ namespace XSDDiagram
LoadSchema(Options.InputFile); LoadSchema(Options.InputFile);
foreach (var rootElement in Options.RootElements) foreach (var rootElement in Options.RootElements)
{ {
foreach (var element in schema.Elements) string elementName = rootElement;
{ string elementNamespace = null;
if (element.Name == rootElement) if (!string.IsNullOrEmpty(elementName))
{ {
diagram.Add(element.Tag, element.NameSpace); var pos = rootElement.IndexOf("@");
} if (pos != -1)
} {
} elementName = rootElement.Substring(0, pos);
elementNamespace = rootElement.Substring(pos + 1);
}
}
foreach (var element in schema.Elements)
{
if ((elementNamespace != null && elementNamespace == element.NameSpace && element.Name == elementName) ||
(elementNamespace == null && element.Name == elementName))
{
diagram.Add(element.Tag, element.NameSpace);
}
}
}
for (int i = 0; i < Options.ExpandLevel; i++) for (int i = 0; i < Options.ExpandLevel; i++)
{ {
diagram.ExpandOneLevel(); diagram.ExpandOneLevel();

View File

@ -35,7 +35,7 @@ namespace XSDDiagram
//static extern bool AllocConsole(); //static extern bool AllocConsole();
static string usage = @"XSD Diagram, version {0} static string usage = @"XSD Diagram, version {0}
Usage: {1} [-o output.svg] [-os EXTENSION] [-r RootElement]* [-e N] [-d] [-z N] [-f PATH,NAME,TYPE,NAMESPACE,COMMENT] [-y] [-u USERNAME] [-p PASSWORD] [file.xsd or URL] Usage: {1} [-o output.svg] [-os EXTENSION] [-r RootElement[@namespace]]* [-e N] [-d] [-z N] [-f PATH,NAME,TYPE,NAMESPACE,COMMENT] [-y] [-u USERNAME] [-p PASSWORD] [file.xsd or URL]
-o FILE -o FILE
specifies the output image. '.png','.jpg', '.svg', '.txt', '.csv' ('.emf' on Windows) are allowed. specifies the output image. '.png','.jpg', '.svg', '.txt', '.csv' ('.emf' on Windows) are allowed.
@ -47,6 +47,7 @@ Usage: {1} [-o output.svg] [-os EXTENSION] [-r RootElement]* [-e N] [-d] [-z N]
-r ELEMENT -r ELEMENT
specifies the root element of the tree. specifies the root element of the tree.
You can put several -r options = several root elements in the tree. You can put several -r options = several root elements in the tree.
The element can have a namespace: MyElement@http://mynamespace/path
-e N -e N
specifies the expand level (from 0 to what you want). specifies the expand level (from 0 to what you want).
Be carefull, the result image can be huge. Be carefull, the result image can be huge.
@ -68,7 +69,7 @@ Usage: {1} [-o output.svg] [-os EXTENSION] [-r RootElement]* [-e N] [-d] [-z N]
Example 1: Example 1:
> XSDDiagramConsole.exe -o file.png -r TotoRoot -r TotoComplexType -e 3 -d -z 200 ./folder1/toto.xsd > XSDDiagramConsole.exe -o file.png -r TotoRoot -r TotoComplexType@http://mynamespace -e 3 -d -z 200 ./folder1/toto.xsd
will generate a PNG image from a diagram with a root elements will generate a PNG image from a diagram with a root elements
'TotoRoot' and 'TotoComplexType', and expanding the tree 'TotoRoot' and 'TotoComplexType', and expanding the tree
from the root until the 3rd level, with the documentation. from the root until the 3rd level, with the documentation.
@ -155,9 +156,22 @@ Example 5:
foreach (var rootElement in Options.RootElements) foreach (var rootElement in Options.RootElements)
{ {
foreach (var element in schema.Elements) string elementName = rootElement;
string elementNamespace = null;
if(!string.IsNullOrEmpty(elementName))
{
var pos = rootElement.IndexOf("@");
if(pos != -1)
{
elementName = rootElement.Substring(0, pos);
elementNamespace = rootElement.Substring(pos + 1);
}
}
foreach (var element in schema.Elements)
{ {
if (element.Name == rootElement) if ((elementNamespace != null && elementNamespace == element.NameSpace && element.Name == elementName) ||
(elementNamespace == null && element.Name == elementName))
{ {
Log("Adding '{0}' element to the diagram...\n", rootElement); Log("Adding '{0}' element to the diagram...\n", rootElement);
diagram.Add(element.Tag, element.NameSpace); diagram.Add(element.Tag, element.NameSpace);

View File

@ -35,11 +35,11 @@ QUICK START:
COMMAND LINE USAGE: COMMAND LINE USAGE:
> XSDDiagram.exe [-o output.svg] [-os EXTENSION] [-r RootElement]* [-e N] [-d] [-z N] [-y] [-u USERNAME] [-p PASSWORD] [file.xsd or URL] > XSDDiagram.exe [-o output.svg] [-os EXTENSION] [-r RootElement[@namespace]]* [-e N] [-d] [-z N] [-y] [-u USERNAME] [-p PASSWORD] [file.xsd or URL]
or on Windows use 'XSDDiagramConsole.exe' instead of 'XSDDiagram.exe' if you need the console: or on Windows use 'XSDDiagramConsole.exe' instead of 'XSDDiagram.exe' if you need the console:
> XSDDiagramConsole.exe [-o output.svg] [-os EXTENSION] [-r RootElement]* [-e N] [-d] [-z N] [-f PATH,NAME,TYPE,NAMESPACE,COMMENT] [-y] [-u USERNAME] [-p PASSWORD] [file.xsd or URL] > XSDDiagramConsole.exe [-o output.svg] [-os EXTENSION] [-r RootElement[@namespace]]* [-e N] [-d] [-z N] [-f PATH,NAME,TYPE,NAMESPACE,COMMENT] [-y] [-u USERNAME] [-p PASSWORD] [file.xsd or URL]
Options: Options:
@ -74,7 +74,7 @@ Options:
Example 1: Example 1:
> XSDDiagramConsole.exe -o file.png -r TotoRoot -r TotoComplexType -e 3 -d -z 200 ./folder1/toto.xsd > XSDDiagramConsole.exe -o file.png -r TotoRoot -r TotoComplexType@http://mynamespace -e 3 -d -z 200 ./folder1/toto.xsd
will generate a PNG image from a diagram with a root elements will generate a PNG image from a diagram with a root elements
'TotoRoot' and 'TotoComplexType', and expanding the tree 'TotoRoot' and 'TotoComplexType', and expanding the tree
from the root until the 3rd level, with the documentation. from the root until the 3rd level, with the documentation.
@ -133,9 +133,10 @@ TODO LIST:
CHANGES: CHANGES:
version 1.2alpha (2016-09-??) version 1.2alpha (2016-11-??)
- Add infer XSD from XML menu. - Add infer XSD from XML menu.
- Fix a null reference exception in the documentation (Thanks Mario M.). - Fix a null reference exception in the documentation (Thanks Mario M.).
- Add the namespace in the command line option -r (Thanks Kevin)
version 1.1 (2016-07-08) version 1.1 (2016-07-08)
- Fix SVG page size. - Fix SVG page size.

Binary file not shown.

Binary file not shown.