Package schema2template.model
Class XMLModel
- java.lang.Object
-
- schema2template.model.XMLModel
-
public class XMLModel extends Object
The most important model, the first access to the XML Schema information.Provides all XML attribute and XML element definitions from the schema. All further information can be accessed from those definitions (e.g. dependencies, constant values, data types, etc.).
-
-
Field Summary
Fields Modifier and Type Field Description StringmLastSchemaFileNamecom.sun.msv.grammar.ExpressionmRootExpression
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringcamelCase(String raw)Convert a-few:words into AFewWords in CamelCase spellingstatic StringcamelCase(QNamed def)Convert a-few:words into AFewWords in CamelCase spellingstatic StringconstantCase(String raw)Convert a-few:words into A_FEW_WORDS in spelling used for Java constantsstatic StringconstantCase(QNamed def)Convert a-few:words into A_FEW_WORDS in spelling used for Java constantsstatic StringescapeKeyword(String in)(Java) Keyword may not start with a number, so escape itstatic StringescapeKeyword(QNamed in)(Java) member variable may not start with a number, so escape itstatic StringescapeLiteral(String in)Escape the quotation marks of String literalsstatic StringescapeLiteral(QNamed in)Escape the quotation marks of String literalsstatic StringextractLocalname(String name)Extract localname local from ns:local namestatic StringextractLocalname(QNamed def)Extract localname local from ns:local namestatic StringextractNamespace(String name)Extract namespace ns from ns:local namestatic StringextractNamespace(QNamed def)Extract namespace ns from ns:local namestatic StringfirstWord(String raw)Assist method for camel-case adaptions or namespace extraction.static StringfirstWord(QNamed def)Maybe not used anymore: Get first word out of a QNamed object containing delimiters like "-:/ _.,"QNamedPuzzleComponentgetAttribute(String name)Get attribute by tag name.PuzzlePiecegetAttribute(String name, int hashCode)Get attribute by tag name and hash code.PuzzlePieceSetgetAttributes()Get all attributes, sorted by ns:local name.QNamedPuzzleComponentgetElement(String name)Get element(s) by tag name.PuzzlePiecegetElement(String name, int hashCode)Get element by tag name and hash code.PuzzlePieceSetgetElements()Get all elements, sorted by ns:local name.static StringjavaCase(String raw)Convert a-few:words into aFewWords in spelling for java method namesstatic StringjavaCase(QNamed def)Convert a-few:words into aFewWords in spelling for java method namesstatic StringlastWord(String raw)Maybe not used anymore: Get last word out of a String containing delimiters like "-:/ _.,"static StringlastWord(QNamed def)Maybe not used anymore: Get last word out of a String containing delimiters like "-:/ _.,"static com.sun.msv.grammar.ExpressionloadSchema(File rngFile)Load and parse a Schema from File.
-
-
-
Field Detail
-
mRootExpression
public com.sun.msv.grammar.Expression mRootExpression
-
mLastSchemaFileName
public String mLastSchemaFileName
-
-
Constructor Detail
-
XMLModel
public XMLModel(File schemaFile)
Constructs new model by the MSV root expression- Parameters:
root- MSV root Expression
-
-
Method Detail
-
loadSchema
public static com.sun.msv.grammar.Expression loadSchema(File rngFile)
Load and parse a Schema from File.- Parameters:
Schema- file (RelaxNG or W3C schema)- Returns:
- MSV Expression Tree (more specific: The tree's MSV root expression)
- Throws:
Exception
-
getElements
public PuzzlePieceSet getElements()
Get all elements, sorted by ns:local name.- Returns:
- Unmodifiable SortedSet of elements
-
getAttributes
public PuzzlePieceSet getAttributes()
Get all attributes, sorted by ns:local name.- Returns:
- Unmodifiable SortedSet of attributes
-
getElement
public QNamedPuzzleComponent getElement(String name)
Get element(s) by tag name. If there are multiple elements sharing the same tag name, a PuzzlePieceSet is returned. If not, a single PuzzlePiece is returned.- Parameters:
name-- Returns:
- Element PuzzlePiece(s)
-
getElement
public PuzzlePiece getElement(String name, int hashCode)
Get element by tag name and hash code. The hash code distincts elements from sharing the same tag name.- Parameters:
name-hashCode-- Returns:
- Element PuzzlePiece
-
getAttribute
public QNamedPuzzleComponent getAttribute(String name)
Get attribute by tag name. If there are multiple attributes sharing the same tag name, a PuzzlePieceSet is returned. If not, a single PuzzlePiece is returned.- Parameters:
name-- Returns:
- Attribute PuzzlePiece(s)
-
getAttribute
public PuzzlePiece getAttribute(String name, int hashCode)
Get attribute by tag name and hash code. The hash code distincts Attributes sharing the same tag name.- Parameters:
name-hashCode-- Returns:
- Attribute PuzzlePiece
-
camelCase
public static String camelCase(String raw)
Convert a-few:words into AFewWords in CamelCase spelling- Parameters:
raw- input String- Returns:
- filtered output String
-
camelCase
public static String camelCase(QNamed def)
Convert a-few:words into AFewWords in CamelCase spelling- Parameters:
def- input- Returns:
- filtered output String
-
javaCase
public static String javaCase(String raw)
Convert a-few:words into aFewWords in spelling for java method names- Parameters:
raw- input String- Returns:
- filtered output String
-
javaCase
public static String javaCase(QNamed def)
Convert a-few:words into aFewWords in spelling for java method names- Parameters:
def- input- Returns:
- filtered output String
-
constantCase
public static String constantCase(String raw)
Convert a-few:words into A_FEW_WORDS in spelling used for Java constants- Parameters:
raw- input String- Returns:
- filtered output String
-
constantCase
public static String constantCase(QNamed def)
Convert a-few:words into A_FEW_WORDS in spelling used for Java constants- Parameters:
def- input- Returns:
- filtered output String
-
firstWord
public static String firstWord(String raw)
Assist method for camel-case adaptions or namespace extraction. Maybe not used anymore: Get first word out of a String containing delimiters like "-:/ _.,"- Parameters:
raw- input String- Returns:
- filtered output String
-
firstWord
public static String firstWord(QNamed def)
Maybe not used anymore: Get first word out of a QNamed object containing delimiters like "-:/ _.,"- Parameters:
def- input- Returns:
- first word
-
lastWord
public static String lastWord(String raw)
Maybe not used anymore: Get last word out of a String containing delimiters like "-:/ _.,"- Parameters:
raw- input- Returns:
- last word
-
lastWord
public static String lastWord(QNamed def)
Maybe not used anymore: Get last word out of a String containing delimiters like "-:/ _.,"- Parameters:
def- input- Returns:
- last word
-
escapeKeyword
public static String escapeKeyword(QNamed in)
(Java) member variable may not start with a number, so escape it- Parameters:
in- raw input- Returns:
- filtered output, starting with a literal
-
escapeKeyword
public static String escapeKeyword(String in)
(Java) Keyword may not start with a number, so escape it- Parameters:
in- raw input- Returns:
- filtered output, starting with a literal
-
escapeLiteral
public static String escapeLiteral(QNamed in)
Escape the quotation marks of String literals- Parameters:
in- raw input- Returns:
- filtered output, with escaped quotation marks
-
escapeLiteral
public static String escapeLiteral(String in)
Escape the quotation marks of String literals- Parameters:
in- raw input- Returns:
- filtered output, with escaped quotation marks
-
extractNamespace
public static String extractNamespace(String name)
Extract namespace ns from ns:local name- Parameters:
name- in form ns:local- Returns:
- ns part from ns:local name
-
extractNamespace
public static String extractNamespace(QNamed def)
Extract namespace ns from ns:local name- Parameters:
def- QNamed object- Returns:
- ns part from ns:local name
-
extractLocalname
public static String extractLocalname(String name)
Extract localname local from ns:local name- Parameters:
name- in form ns:local- Returns:
- local part from ns:local name
-
-