The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,163 other followers

Archive for the ‘XML/XSD’ Category

Delphi, soap and wrapping values in cdata – Stack Overflow

Posted by jpluimers on 2020/09/15

For my link archive: [WayBack] Delphi, soap and wrapping values in cdata – Stack Overflow

–jeroen

Posted in Delphi, Development, SOAP/WebServices, Software Development, XML/XSD | Leave a Comment »

Not all XSD mappings to programming language constructs are possible

Posted by jpluimers on 2020/02/26

This post is a reminder to myself that not all mappings from XSD to programming languages are possible.

There are many impossible cases, so this is just a general reminder.

A Delphi specific case for instance is the mapping of enumerations: one reason is that XSD enumerations are case sensitive, but the Delphi language is not: [WayBackUsing XML Enumerations with Delphi XML Data Binding Wizard – Stack Overflow.

More generic examples from my answer to the above question:

  • In XSD you can derive from an existing type in two ways: extending it and limiting it. Object Oriented languages only allow you extend when deriving.
  • Delphi is not alone in these kinds of limitations. Generating wrappers from XSD schema’s is the field of specialized tools, even in the Java or .NET world.

I’ve seen horrible things with wildcards that are sort of mappable to Java, but not to C#. This could likely go on for much longer…

–jeroen

Posted in C#, Delphi, Development, Java, Java Platform, Software Development, XML, XML/XSD, XSD | 2 Comments »

Offline XML Pretty Print

Posted by jpluimers on 2019/12/20

I wrote about [WayBackXML Pretty Print in Online XML Pretty Print many years ago.

That’s all fine for small XML file and on-line usage.

A while ago however, I had two cases where off-line XML pretty printing turned out to be much easier than online XML pretty printing:

  1. pretty-print many XML files in one go
  2. compare large (100 megabyte plus) XML files

So I went searching, especially for a solution that would be available for both nx based platforms (Linux/Mac OS X/etc) and Windows which got me a few options in [WayBack] unix – How to pretty print XML from the command line? – Stack Overflow.

I found [WayBack] tidy to be more practical than [WayBack] xmllint as tidy would split more lines which made it easier for  Beyond Compare (that is very much cross platform!) to spot and show the differences.

Not just easier in the sense that the (already excellent) diff engine from Beyond Compare (which really sets it apart from other differencing tools) but very much easier on the eyes as now differences where on lines below each other in stead of 1000s of character positions in one line you had to scroll through.

There is two important things to remember with tidy that both stem from its ancestry (it originates from an HTML):

  • you have to specify -xml
  • you have to specify the characterset (even though XML can specify it and without a definition, XML by default is UTF8, tidy does not know about that)

These were the command-lines I used on Windows to do the pretty printing:

tidy -xml -utf8 QCScaper.test@borland.com.cds.xml > QCScaper.test@borland.com.tidy.cds.xml
xmllint --format QCScaper.test@borland.com.cds.xml > QCScaper.test@borland.com.pretty-printed.cds.xml

Another trick is to write a small Delphi program centered around the FormatXMLData call which has been present since Delphi 2007 (see [WayBack] devnet.pdf), but documented since Delphi 2009 in [WayBack] XMLDoc.FormatXMLData Function.

Example code: [WayBack] delphi – How to reformat XML programmatically? – Stack Overflow.

An alternative is to use OmniXML: [WayBack] delphi – Nice bit of code to format an xml string – Stack Overflow

–jeroen

Related posts:

Read the rest of this entry »

Posted in Beyond Compare, Development, Power User, XML, XML/XSD | Leave a Comment »

… compare two JSON structures and pin-point … the differences – – Nicholas Ring – Google+

Posted by jpluimers on 2019/08/20

I’ve added a few WayBack/Archive.is links to the interesting comments by Zoë Peterson from Scooter Software (of Beyond Compare fame) at [WayBack] … compare two JSON structures and pin-point … the differences – – Nicholas Ring – Google+:

Beyond Compare 4 has an optional “JSON sorted” file format that uses jq to pretty print and sort JSON data before comparing it. It’s not included out of the box yet, but you can get a copy here:

If you’re interested in an actual algorithm and not just an app, I don’t have a suggestion handy, but could dig one up. Tree alignment is more complicated than sequence alignment and we did do research into it, but it was quite a few years ago and didn’t get incorporated into BC. XML alignment algorithms were being actively researched back in the aughts and they should trivially transfer to JSON.

It looks like our research mostly ended around 2002, and I wasn’t personally involved in it, so I don’t know how helpful this will be, but here’s what I have:

The general idea in the thread is that JSON – though not as formalised as XML – does have structure, so if you can normalise it, then XML ways of differencing should work.

Normalisation also means that you need to normalise any floating point, date time, escaping, quoting, etc. Maybe not for the faint of heart.

–jeroen

Posted in Beyond Compare, Development, JavaScript/ECMAScript, JSON, Power User, Scripting, Software Development, XML/XSD | Leave a Comment »

detect availability of node-set() function in xslt implementation of icecast server – Stack Overflow

Posted by jpluimers on 2019/03/07

Wow, I totally forgot I had done this xslt trick eons ago: [WayBackdetect availability of node-set() function in xslt implementation of icecast server – Stack Overflow

–jeroen

Posted in Development, Software Development, XML/XSD, XSLT | Leave a Comment »

 
%d bloggers like this: