Posted by jpluimers on 2016/10/12
A while ago, I heard about xmllint, a program that can parse and query xml from the command-line.
Later, I discovered it can also parse html, can recover from xml/html errors and has an interactive shell that has a lot of commands (see table below) to navigate through the loaded command.
The relevant command-line options:
--recover will output failing input to
stderr. You can ignore that using
Some good examples of usage are here:
The table of shell commands:
xmllint offers an interactive shell mode invoked with the –shell command. Available commands in shell mode include:
||display XML base of the node
||Display node if given or current node.
||Change the current node to path (if given and unique) or root if no argument given.
||Dumps information about the node (namespace, attributes, content).
||Show the structure of the subtree under path or the current node.
||Leave the shell.
||Show this help.
||Display memory usage.
||Load a new document with the given name.
||List contents of path (if given) or the current directory.
||Display the path to the current node.
||Leave the shell.
||Saves the current document to name if given or to the original name.
||Check the document for error.
||Write the current node to the given filename.
Posted in Development, HTML, HTML5, Software Development, Web Development, XML, XML/XSD, XPath | Leave a Comment »
Posted by jpluimers on 2016/07/27
It comes down to these cases for XML
maxOccurs="1" (which the default for
nillable="true" will convert from a regular type to a nullable type.
minOccurs="0" will add boolean …Specified properties in the generated C# for each element.
- you can have both
minOccurs="0" in an element which gets you a nullable type and a …Specified property.
Note I’m not considering
default here, nor
attributes (that have
use instead of
maxOccurs, but do not allow for nillable) nor larger values of
maxOccurs (which both xsd.exe and xsd2code regard as
From the above, XML has a richer type system than C#, so in XML there are subtle a differences between:
- an explicit
nil in the XML element
- the XML element being absent
- the XML element being empty.
Hopefully later more text and examples to show how to actually work with this.
From the specs:
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, C# 6 (Roslyn), Development, Software Development, XML, XML/XSD, XSD | Leave a Comment »
Posted by jpluimers on 2016/04/26
One of the things you cannot do in XSD, is have string enumerations contain both a key and a value.
But there is a little appinfo trick inside annotation that you can user under some circumstances, for instance when you interpret the XSD:
appinfo is the application counterpart of documentation: both can contain any xml, but appinfo is aimed at machines, whereas documentation is aimed at humans.
Posted in Development, Software Development, XML, XML/XSD, XSD | Leave a Comment »
Posted by jpluimers on 2015/07/22
See the gist below:
Example of xsd2code only handling xsd annotations for attributes, not for elements, types and other places where they can be used in an XSD.
Steps to reproduce:
- Install xsd2code and Visual Studio.
- Put all these files in one directory.
- Run `generate-C#-from-XSD-annotations.bat`.
- Diff `annotations.xsd.exe.cs` and `annotations.xsd2code.exe.cs`.
- Observe only 1 spot in `annotations.xsd2code.exe.cs` has the annotations converted to C# comments.
Gist: Example of xsd2code only handling xsd annotations for attributes, not for elements, types and other places where they can be used in an XSD. Steps to reproduce.
Read the rest of this entry »
Posted in .NET, Software Development, Development, C#, XML/XSD, C# 2.0, XML, C# 3.0, XSD, C# 4.0, .NET 4.5, C# 5.0, .NET 3.5, .NET 2.0, .NET 3.0, .NET 4.0, C# 6 (Roslyn) | Leave a Comment »