In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "the method of expanding enumerated list in XML mode". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Listing 1. Enumerated list of marital status
Suppose a company wants to use these values, and in addition, support its important trading partners to use another value. CivilUnion is an extended value that the company recognizes that does not belong to the original schema. But semantically, it is also possible to use an existing element-MaritalStatus. How can the company achieve it?
Go back to the top of the page
Solution 1: edit the original schema to include new enumerated values
Of course, editing the original schema to include the new enumerated values is the most direct way. Keep a local copy of the pattern, and then edit the patterns to support the enumerated values used by the company.
Pros: easy to implement
Disadvantages:
The original schemas need to be edited, and these schemas will gradually change out of control. If you extend a pre-existing list, the creator (trading partner, association, etc.) may want to release a new version of the list. You need to propagate your edits to each new version.
Manual editing mode can cause unexpected editing errors.
If you cannot (or do not want to) edit the original schema, you need an alternative.
Go back to the top of the page
Solution 2: create a new enumeration list and add it to the original list
The second option is to create a new enumeration list and add it to the original enumeration list. Listing 1 shows a list of the original marital status. Listing 2 shows the list of newly created enumerations.
Listing 2. Enumerated list of new marital status
Use tags to combine it with the original list, as shown in listing 3.
Listing 3. Combine the two lists
The solution still needs to edit the schema-converting the element MaritalStatus from MaritalStatusType type to MaritalStatusType_Union type. There is not much change, but there is still some manual editing work.
Advantage: does not change the original enumerated list.
Disadvantages:
All values must be known during the design phase to prevent late binding of the solution.
Tag support is required, but sometimes the tag cannot be implemented with tools.
Go back to the top of the page
Solution 3: create a schema and combine it with the original enumeration type
Now take a look at the demographic data use case for eye color. Listing 4 shows this list.
Listing 4. Person Eye Color enumerated list
Next, create a pattern (a regular expression) that takes the new value. The pattern is any string prefixed with x:. X: is a descriptor between a standard enumerated list and an extended list. Listing 5 shows this pattern.
Listing 5. Regular expressions for extension
Finally, use tags to combine lists with patterns, as shown in listing 6.
Listing 6. The combination of enumerated lists and extended modes
The same node has standard and extended values. The two values are easy to separate and can be validated with a parser, as shown in listing 7.
Listing 7. Sample XML instance
Black
X:Teal
Advantages:
The same element can be used for all data.
Validate the basic enumeration list with a parser.
Clearly separate the extended values.
The solution allows new values to be bound at a later time.
Disadvantages:
The contents of the element must be parsed to determine if it has been extended.
The pattern parser must support regular expressions.
Tag support is required.
Go back to the top of the page
Solution 4: use separate fields for extension
In this solution, the enumerated fields do not change.
This is the end of the content of "methods for extending enumerated lists in XML mode". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.