[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Help with XML anti pattern

  • From: William David Velasquez <wd@creativosdigitales.co>
  • To: XML Developers List <xml-dev@lists.xml.org>
  • Date: Tue, 23 Nov 2021 13:21:25 -0500

Help with XML anti pattern

Hi XML folks,

I want to share here a real case to ask for your wisdom and advice:

This week my company started to work in a project involving a customization of UBL Invoices. A team before us, defined a structure similar to this for receiving the name of a person and the name of a software product:

<ext:UBLExtension>
  <ext:ExtensionContent>
   <SWMaker>
    <SWMakerInfo>
      <Name>FirstName</Name>
      <Value>Erick</Value>
      <Name>LastName</Name>
      <Value>Rich</Value>
      <Name>SWName</Name>
      <Value>FancySoft v.1.0</Value>
    </SWMakerInfo>
  </SWMaker>
 </ext:ExtensionContent>
</ext:UBLExtension>

This way of modeling data is opposite to the essence of XML, but frequently used by programmers that sells it as "flexible" because it can accommodate future uses with new combinations for elements "Name" and "Value" (and because many programming languages translate object dictionaries to this kind of XML).

The problem arrives when XPath expressions become more complex (although not impossible to write) to access data:

For example, to get the first name:

ext:UBLExtension/*:ExtensionContent/SWMaker/SWMakerInfo/Name[ . = "FirstName" ]/following-sibling::Value[1]

But this kind of expression is not trustworthy. For example, if the first <Value> element is missing, the LastName will be returned instead.

I'm asking for your help, because we'll have a meeting with the contractor and I need arguments to convince them of changing to a
"Natural" XML structure like this:

<SWMaker>
  <SWMakerInfo>
    <FirstName>Erick</FirstName>
    <LastName>Rich</LastName>
    <SWName>FancySoft v.1.0</SWName>
  </SWMakerInfo>
</SWMaker>


I'm expecting customer won't be open to accept the change, because the actual structure can do the work.

So, what arguments would you use to convince the customer?

Thanks in advance for all your input. It is very enriching to read your opinions and learn from all your experience.

 

-- 
William David Velasquez
Creativo de Software
Creativos Digitales S.A.S.



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.