-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discard XML namespaces #608
Comments
I think you greatly underestimate the benefits of XML support built into the language. XML is probably the main reason why I still use VB. For me, XML support in the language makes a world of difference. I don't do a lot of 'original' app development - but I do a lot of work in XML writing integrations for the ERP systems that I support. I can have embedded XML that is 100's of lines long (although I usually break them up into smaller pieces for maintainability). Once you know how to use it, the XML support in VB is invaluable for this. And code involving embedded XML is much easier to read than anything using methods to achieve the same result. For one of the products I support, their API is XML only, and they provide sample XML files for all the inputs to the API. Because of limitations of working with this particular ERP system, I can't use .NET's built-in serialization, and I have to do it all 'by hand'. With VB, I can grab some sample XML, paste it into my VB code, and then replace the hard-coded values with properties from my class. In any other language, the only way to do the same thing as easily is to use strings to build the XML. But then I still have string, which I'd need to convert to some kind of XML document before I could use it. In the absence of VB's built-in language support for XML, if you want the wrappers of XDocument or XmlDocument, you'd have a LOT more work to do. For example, this bit of code, part of a much larger class for generating ISO20022 international payment files, would be MUCH more complicated in anything other than embedded XML: Private Shared Function PaymentGroupHeader(eft As EftPayments, paymentType As PaymentType, groupSum As Decimal, groupPayments As Integer) As XElement
Return <PmtInf>
<PmtInfId><%= $"{eft.EftHeader.EftBatch}{paymentType}" %></PmtInfId>
<PmtMtd>TRF</PmtMtd>
<BtchBookg><%= If(String.Equals(eft.EftHeader.StatementDetailLevel, "batch", StringComparison.OrdinalIgnoreCase), "true", "false") %></BtchBookg>
<NbOfTxs><%= groupPayments %></NbOfTxs>
<CtrlSum><%= groupSum.ToString("0.000") %></CtrlSum>
<PmtTpInf>
<InstrPrty><%= If(paymentType = PaymentType.CBFT, "HIGH", "NORM") %></InstrPrty>
<SvcLvl>
<Cd><%= If(paymentType = PaymentType.CBFT, "URGP", "NURG") %></Cd>
</SvcLvl>
</PmtTpInf>
<ReqdExctnDt><%= eft.EftHeader.ActionDate.ToIsoDate() %></ReqdExctnDt>
<Dbtr>
<Nm><%= eft.EftHeader.PayerName %></Nm>
<PstlAdr>
<AdrLine><%= eft.EftHeader.CompanyAddressLine1 %></AdrLine>
<AdrLine><%= eft.EftHeader.CompanyAddressLine2 %></AdrLine>
<PstlAdr><%= eft.EftHeader.CompanyAddressLine7 %></PstlAdr>
<Ctry><%= eft.EftHeader.BankCountryCode %></Ctry>
<PstCd><%= eft.EftHeader.CompanyAddressLine7 %></PstCd>
</PstlAdr>
</Dbtr>
<DbtrAcct>
<Id>
<%=
If(String.IsNullOrWhiteSpace(eft.EftHeader.IBAN),
<Othr><Id><%= eft.EftHeader.BankAccount %></Id></Othr>,
<IBAN><%= eft.EftHeader.IBAN %></IBAN>
)
%>
</Id>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<BIC><%= eft.EftHeader.BIC %></BIC>
<ClrSysMmbId>
<ClrSysId>
<MmbId><%= eft.EftHeader.MmbId %></MmbId>
</ClrSysId>
</ClrSysMmbId>
</FinInstnId>
<BrnchId>
<Id><%= eft.EftHeader.BranchId %></Id>
</BrnchId>
</DbtrAgt>
<UltmtDbtr>
<Nm><%= eft.EftHeader.PayerName %></Nm>
</UltmtDbtr>
<ChrgBr>DEBT</ChrgBr>
</PmtInf>
End Function
|
I can't understand what you are asking for here. There is a gab between the title and your description, so, can you give us a sample of code that shows what is wrong and how you suggest to fix it? What do you mean by |
In practical application, the XML fragment mixed in the code will not be too long. If it is too long, it will be stored in the file, and then read and write through the XML processing class, without processing at the syntax level. Today's vb.net introduces XML at the syntax level, which makes the parser more complex and not conducive to maintenance. The benefits from this are not great, and the language users are not easy to understand.
The text was updated successfully, but these errors were encountered: