Subject: Re: [xsl] Convert JSON to XML? From: "Tony Graham tgraham@xxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 2 May 2025 15:18:24 -0000 |
On 02/05/2025 13:07, Michael B Allen ioplex@xxxxxxxxx wrote: [...]For example, it is commonplace to do something like the following:
<address> \xA0\xA0 <street>123 Main St</street> \xA0\xA0 <city>Townville</city> \xA0\xA0 <state>PA</state> </address>
IMO the "correct" form for an XML element is to put values that are not divisible into attributes
I respectfully disagree. The canonical test is for values known or attested to be discrete (eg standard State or Country abbreviations)
to be attribute values (preferably in a token list [enumerated] if possible); and values which are infinitely variable (eg street addresses) to be plain text content (PCDATA).
But it's a sliding scale and no single answer is "correct":
Another "correct" form is to avoid using attribute values for user readable content because that can make translation somewhere between difficult and impossible:
I couldn't see anything in the Best Practices about enumerable alternatives, but it probably depends on to what extent you consider something like a state abbreviation to be user readable content (and when and how you're going to process the content before presenting it to a user).
Anyway, my point is that the only "correct" way to convert JSON to XML is to understand in advance which of the many XML representations is "correct" for your particular application and then write code to explicitly perform that conversion.
Best way.
Tony Graham. -- Senior Architect XML Division Antenna House, Inc. ---- Skerries, Ireland tgraham@xxxxxxxxxxxxx
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Convert JSON to XML?, Peter Flynn peter@xx | Thread | Re: [xsl] Convert JSON to XML?, Michael B Allen iopl |
Re: [xsl] What is the correct xpath, ajbufort@xxxxxxxxxxx | Date | Re: [xsl] Convert JSON to XML?, Wendell Piez wapiez@ |
Month |