Archive for the ‘XML/XSD’ Category
Posted by jpluimers on 2022/02/15
[Wayback] WILT: XML encode a string in .net « Benoit MARTIN’s Weblog:
Always wondered why I couldn’t find a method that would XML encode a string, effectively escaping the 5 illegal characters for XML. There is such a method but its location in the API is not intuitive at all. It’s in the System.Security namespace: [Wayback] SecurityElement.Escape(String) Method (System.Security) | Microsoft Docs
public static string? Escape (string? str);
Its usage is:
tagText = System.Security.SecurityElement.Escape(tagText);
This will escape the 5 characters <, >, &, " and '
–jeroen
Posted in .NET, Development, Encoding, Software Development, XML, XML escapes, XML/XSD | Leave a Comment »
Posted by jpluimers on 2021/08/31
This helped me big time finding failed logon attempts: [WayBack] Event Log Hell (finding user logon & logoff) – Ars Technica OpenForum
Alternatively, you can use the XPath query mechanism included in the Windows 7 event viewer. In the event viewer, select “Filter Current Log…”, choose the XML tab, tick “Edit query manually”, then copy the following to the textbox:
Code:
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">*[System[EventID=4624] and EventData[Data[@Name='TargetUserName'] = 'USERNAME']]</Select>
</Query>
</QueryList>
This selects all events from the Security log with EventID 4624 where the EventData contains a Data node with a Name value of TargetUserName that is equal to USERNAME. Remember to replace USERNAME with the name of the user you’re looking for.
If you need to be even more specific, you can use additional XPath querying – have a look at the detail view of an event and select the XML view to see the data that you are querying into.
Thanks user Hamstro!
Notes:
- you need to perform this using
eventvwr.exe running as an elevated process using an Administrative user CUA token.
USERNAME needs to be the name of the user in UPPERCASE.
- replacing
TargetUserName with subjectUsername (as suggested by [WayBack] How to Filter Event Logs by Username in Windows 2008 and higher | Windows OS Hub) fails.
- there are more relevant EventID values you might want to filter on (all links have screenshot and XML example of an event):
- blank (empty passwords) can only be used for local logon, so they disable network logon. That can be a useful security strategy.
Related:
–jeroen
Posted in Development, Microsoft Surface on Windows 7, Power User, Software Development, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows 9, Windows Vista, Windows XP, XML/XSD | Leave a Comment »
Posted by jpluimers on 2021/05/27
A few links for my link archive, as I often edit XML files (usually with different extensions than .xml, because historic choices that software development vendors make, which makes it way harder to tell editors “yes, this too is XML).
- Visual Studio Code
- Visual Studio
- [WayBack] XPath Tools – Visual Studio Marketplace: Extension for Visual Studio – Run XPaths and XPath functions. Browse through results at the click of a button.Track and copy XPaths incl. XML namespaces in various formats, taking the hassle out of complex documents
- Via:
- Notepad++ (note you have to install the plugin as Administrator, and restart Notepad++ to take effect)
–jeroen
Read the rest of this entry »
Posted in .NET, Development, Notepad++, Power User, Software Development, Text Editors, Visual Studio and tools, vscode Visual Studio Code, XML, XML/XSD | Leave a Comment »
Posted by jpluimers on 2021/05/13
Sometimes an install is not just as simple as C:\>choco install --yes oracle-sql-developer.
Edit 20210514:
Note that most of the below pain will be moot in the future as per [Archive.is] Jeff Smith 🍻 on Twitter: “we’re working on removing the SSO requirement, it’s already done for @oraclesqlcl – see here … “ referring to [Wayback] SQLcl now under the Oracle Free Use Terms and Conditions license | Oracle Database Insider Blog
SQLcl, the modern command-line interface for the Oracle Database, can now be downloaded directly from the web without any click-through license agreement.
It means the Oracle acount restriction will be lifted, and downloads will be a lot simpler.
I started with the below failing command, tried a lot of things, then finally almost gave up: Oracle stuff does not want to be automated, which means I should try to less of their stuff.
First of all you need an Oracle account (I dislike companies doing that for free product installs; I’m looking at Embarcadero too) by going to profile.oracle.com:
[WayBack] Chocolatey Gallery | Oracle SQL Developer 18.4.0 (also: gist.github.com/search?l=XML&q=oracle-sql-developer)
Notes
- This version supports both 32bit and 64bit and subsequently does not have a JDK bundled with it. It has a
dependency on the jdk8 package to meet the application’s JDK requirement.
- An Oracle account is required to download this package. See the “Package Parameters” section below for
details on how to provide your Oracle credentials to the installer. If you don’t have an existing account, you can
create one for free here: https://profile.oracle.com/myprofile/account/create-account.jspx
Package Parameters
The following package parameters are required:
* /Username: – Oracle username
* /Password: – Oracle password
(e.g. choco install oracle-sql-developer --params "'/Username:MyUsername /Password:MyPassword'")
To have choco remember parameters on upgrade, be sure to set choco feature enable -n=useRememberedArgumentsForUpgrades.
Then the installation failed fail again: ERROR: The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.
The trick is to RUN IEXPLORE.EXE AS ADMINISTRATOR ONCE BEFORE INSTALLING FROM CHOCOLATEY. Who would believe that.
The reason is that the package uses Invoke-WebRequest which requires Internet Explorer and PowerShell 3. Chocolatey packages however need to be able to run on just PowerShell 2 without Invoke-WebRequest.
Maybe using cURL can remedy that; adding a dependency to is is possible, as cURL can be installed via chocolatey: [WayBack] How to Install cURL on Windows – I Don’t Know, Read The Manual. Another alternative might be [WayBack] Replace Invoke-RestMethod in PowerShell 2.0 to use [WayBack] WebRequest Class (System.Net) | Microsoft Docs.
Read the rest of this entry »
Posted in CertUtil, Chocolatey, CommandLine, Database Development, Development, DVCS - Distributed Version Control, git, Hashing, OracleDB, Power User, PowerShell, Security, SHA, SHA-1, Software Development, Source Code Management, Windows, XML, XML/XSD | Leave a Comment »
Posted by jpluimers on 2021/01/21
I should have had the below answer when writing about StUF – receiving data from a provider where UTF-8 is in fact ISO-8859.
A while ago, a co-worker did not believe when I told that default XML encoding really is UTF-8 (and tried to force it to utf-8), and that if the content had byte sequences different from the (either specified or default) encoding, it was a problem.
I though I blogged about the default, and where to find it, but apparently, I did not.
My blog had (and has <g>) a truckload of articles mentioning UTF-8, less articles containing UTF-8, encoding and xml, but the ones having UTF-8, default, encoding and xml did not actually tell about a standard that really defines XML uses UTF-8 as default encoding when there is no other encoding information – like BOM (byte order mark), HTTP, or MIME encoding) available.
W3C indeed specifies it. [WayBack] utf 8 – How default is the default encoding (UTF-8) in the XML Declaration? – Stack Overflow has a summary (thanks James Holderness!):
The Short Answer
Under the very specific circumstances of a UTF-8 encoded document with no external encoding information (which I understand from the comments is what you’re interested in), there is no difference between the two declarations.
The long answer is far more interesting though.
and an elaboration:
Read the rest of this entry »
Posted in Development, Encoding, Software Development, UTF-8, UTF8, XML, XML/XSD | Leave a Comment »
Posted by jpluimers on 2020/12/08
I don’t do SOAP that often any more, so here some links on it and some notes on how one site used some of the fields:
A few observations from real life:
- Inside the WS-Addressing realm:
Action has a URI indicating what to execute inside the service
From is basically abused because it
- is not used as a
source endpoint but
- has an
Address element that contains both Action and authentication
MessageID uses a uuid: based URI
- Outside the WS-Addressing realm, in the main SOAP body:
Since is implemented using a non ISO-8601 compliant timestamp: it barfs on the second fraction and on the time zone (neither Z nor an offset based time-zone are accepted).
I did not know you could have uuid based URIs, as they are not mentioned here:
But apparently they have been in use for quite a while:
–jeroen
Posted in Development, SOAP/WebServices, Software Development, XML, XML/XSD | Leave a Comment »
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: [WayBack] Using 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 »
Posted by jpluimers on 2019/12/20
I wrote about [WayBack] XML 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:
- pretty-print many XML files in one go
- 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 »
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 *nix, *nix-tools, Beyond Compare, Development, diff, JavaScript/ECMAScript, jq, JSON, Power User, Scripting, Software Development, XML, XML/XSD | Leave a Comment »