CN1799029A - XML types in java - Google Patents
XML types in java Download PDFInfo
- Publication number
- CN1799029A CN1799029A CN 200480002764 CN200480002764A CN1799029A CN 1799029 A CN1799029 A CN 1799029A CN 200480002764 CN200480002764 CN 200480002764 CN 200480002764 A CN200480002764 A CN 200480002764A CN 1799029 A CN1799029 A CN 1799029A
- Authority
- CN
- China
- Prior art keywords
- xml
- type
- data
- java
- readable media
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 claims description 63
- 238000006243 chemical reaction Methods 0.000 claims description 45
- 230000000712 assembly Effects 0.000 claims description 5
- 238000000429 assembly Methods 0.000 claims description 5
- 230000009466 transformation Effects 0.000 claims description 5
- 238000013519 translation Methods 0.000 claims description 4
- 230000005540 biological transmission Effects 0.000 claims description 2
- 230000007812 deficiency Effects 0.000 abstract description 2
- 235000010627 Phaseolus vulgaris Nutrition 0.000 description 10
- 244000046052 Phaseolus vulgaris Species 0.000 description 10
- 238000013507 mapping Methods 0.000 description 9
- 238000010586 diagram Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 7
- 235000006719 Cassia obtusifolia Nutrition 0.000 description 5
- 235000014552 Cassia tora Nutrition 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 5
- 230000008859 change Effects 0.000 description 4
- 150000001875 compounds Chemical class 0.000 description 4
- 244000277285 Cassia obtusifolia Species 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 244000201986 Cassia tora Species 0.000 description 2
- 238000013459 approach Methods 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 230000002950 deficient Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 101100313471 Streptomyces sp getA gene Proteins 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 235000013399 edible fruits Nutrition 0.000 description 1
- 230000002349 favourable effect Effects 0.000 description 1
- 238000007667 floating Methods 0.000 description 1
- 230000008676 import Effects 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 230000009191 jumping Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000000717 retained effect Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
- 238000012800 visualization Methods 0.000 description 1
- 239000011800 void material Substances 0.000 description 1
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The use of XML types can allow the combination of XML- and Java-type systems, which overcomes many deficiencies in existing marshaling and unmarshaling systems by translating XML schemas which define XML data in an XML document into XML types in Java. Unlike traditional attempts at translating between XML and Java, XML schemas realized as XML types can remain fully faithful to the XML, and are capable of a number of XML data operations. In addition, the XML types can be easily transformed among themselves and Java types, and a lightweight store retaining XML information at tag level allows incremental XML marshaling and unmarshaling. This description is not intended to be a complete description of, or limit the scope of, the invention. Other features, aspects, and objects of the invention can be obtained from a review of the specification, the figures, and the claims.
Description
Copyright notice/
The open part of patent document comprises content protected by copyright.The copyright owner does not oppose according to the patent document that occurs in patent and the trademark office or writes down the patent documentation of such Xerox patent publication, otherwise keeps all copyrights.
PRIORITY CLAIM
The application requires the right of priority of following application, and this application is incorporated herein by reference:
U.S. Provisional Application No.60/442673, name is called XML TYPES IN JAVA, and the invention people is DavidBau, and submitting the date is on January 24th, 2003 (lawyer's number of documents BEAS-01388US0 SRM/DTX).
Technical field
The present invention relates to the conversion of data and data type.
Background technology
Current some defective that on the conversion or the mode of array data between different data types, exists.In existing system, the user starts existing java class type and requires system to generate the XML pattern of reflection java class type, and then the Java data ordering is become the XML of automatic generation.The product that great majority are arranged XML all passes through compiler (for example compiler from Java to WSDL) operation, to generate XML pattern (schema).One of defective of this method only is at the situation from Java to XML.Current instrument is not to be good at especially to adopt existing xml schema and whole mode switch is become java class type easy to use.
Another problem of current permutation technology appears at the user when only wanting to check fritter XML data.The user may wish just to jump to remaining XML data under the situation of not handling this XML data block.Current permutation technology is not very effective simply jumping to aspect the remainder data.Usually, redirect is very complicated between different arrangements, because be not that all semantemes among the XML can both be caught in Java at an easy rate.If the user imports message, change the sub-fraction of this message, and attempt this message is resend as XML, then will be dissimilated by the other parts that the user changes the part, thereby lose a lot of out of Memory except this.For example, if XML contains asterisk wildcard attribute or element, then these asterisk wildcards can not be retained.Information about order of elements may also can be lost or multilated, if pattern just becomes a problem to very sensitive this of order of elements.
Description of drawings
Fig. 1 illustrates the example XML schema definition document according to the embodiment of the invention.
Fig. 2 illustrates according to the block diagram embodiment of the invention, that be used for the example system of XML arrangement reconciliation arrangement (marshaling andunmarshaling).
Fig. 3 illustrates by the code sample that can be used for according to the XML type of the XML pattern of embodiment of the invention compiling.
Fig. 4 illustrates the code sample based on the form of note that can be used for according to the embodiment of the invention.
Fig. 5 illustrates the code sample that can be used for according to the realization Web service of the embodiment of the invention.
Fig. 6 illustrates the code sample that can be used for according to the type conversion of the embodiment of the invention.
Fig. 7 illustrates the code sample that is used for the default type statement that can be used for according to the embodiment of the invention.
Fig. 8 illustrates the code sample that is used for the XML conversion that can be used for according to the embodiment of the invention.
Fig. 9 illustrates the code sample that is used for the XML conversion that can be used for according to the embodiment of the invention.
Figure 10 illustrates the block diagram that can be used for according to the example XML converting system of the embodiment of the invention.
Figure 11 illustrates the block diagram that can be used for according to the example system that is used for the XML storage of the embodiment of the invention.
Figure 12 illustrates the block diagram that can be used for according to the example system that is used for the XML pattern of the embodiment of the invention.
Figure 13 illustrates the block diagram according to the example system that is used for the XML type of the embodiment of the invention.
Figure 14 illustrates the example hierarchical diagram according to the embodiment of the invention.
Embodiment
Below with example but not the mode that is restricted to accompanying drawing illustrates the present invention, similar Reference numeral is represented similar parts in the accompanying drawing.Should be noted that in the disclosure document " one " or " one " embodiment same embodiment of definiteness that differs, the meaning of Miao Shuing is at least one like this.
The XML schema translation that will define the XML data when system and method is by array data between XML and Java according to an embodiment of the invention in the XML file is the XML type among the Java, has overcome a lot of deficiencies in the existing arrangement reconciliation arranging system.The XML type be actually except conventional Javabean function and accessing database can also with effective, type safety, robust and easily mode visit and upgrade the java class type of XML data in the Java.Operable at least one embodiment architecture can be handled the almost pattern of 100% user introducing.
The use of XML type is permitted XML type system and java class type system in combination are in the same place.This can realize that loose coupling finishes by permitting the developer.The XML pattern that realizes as the XML type can meet XML fully.The developer is easy to control the accurate transformation between existing java class type and the existing XML type.By adopting several technology simultaneously, for example comprise that strong type turns to from the pattern consciousness of Java visit XML data file, closely and XML storage in the storer of index, fast and minimum (propellings) analyzes and (scale-of-two) serializing, light file cursor move, XPath and XQuery navigation and conversion and seamless Java IDE are integrated is arranged, the XML type can relate to Java/XML and demarcate.
For the example towards XML " XML by Java code to XML ", Fig. 1 illustrates simple examples XML mode-definition (XSD) file that can be used for according to the embodiment of the invention.The type of a purchase order of this specific XML pattern description.This pattern can be the file that is pre-existing in that is generated or created by the user by the pattern instrument.In this example, may need " removing " or " fixing " invalid XML purchase order information.
At the XSD top layer is mode-definition at the element of by name " purchase order ".This element is defined as compound type, and comprises the element of " arrangement project (line-item) " by name." maxOccurs " attribute is set to " unbounded ", and the meaning is that this arrangement project can repeat arbitrary number of times.Each arrangement project has 4 daughter element: desc, itemid, price, qty.Daughter element desc represents it is the descriptive element of character string, and itemid represents it is the item identifier element (type is int) of integer, and price represents it is the price element (type is float) of floating number, and qty represents it is the element of magnitude of integer.These daughter elements all are the built-in types of pattern.This pattern describes basically or shows what an effective purchase order is.
In order to adopt the programming of XML type, the XML schema file can be added in the Java scheme.The exemplary system that is used for XML arrangement reconciliation arrangement is shown in Figure 2.In one embodiment, this system can handle this document with not only knowing the compiler 100 that how to compile Java scheme 101, can also compile XSD file 102.When compiling XSD file, except conventional java class type 104, can also generate a lot of XML Class1 03.These XML types can be added in the class.path (classpath) then.For example, the XML type of " purchase order (puchase order) " by name can generate from the mode type of " purchase-order (puchase-order) " by name.
Expression is shown in Figure 3 with the Java source code of the XML type of the compiling of the example modes among Fig. 1, and the source that wherein generates these java class types is a schema file itself.The type of LineItem by name is corresponding to the arrangement item elements in the purchase order element that embeds in the XSD file.In Java, XML arranges item elements can be converted to similar thing.Can generate the Java file for each element in the type.For example, for the desc element among the XSD, generate getDesc and the setDesc method that all has correspondence in the type in each line item purpose.For whole purchase order, the user can obtain or send indivedual arrangement projects.The title of the type that generates can automatically derive from MODE name.The type of each generation can be explained the associative mode title in its source.Each type can also be expanded existing XML type.
In one embodiment, the XML type can realize the general basic XML type of XMLObject by name.This XML type can be carried out a plurality of data manipulations towards XML, and is called XBean at this.XBean is not the Java bean of standard, but inherits and next XBean from XMLObject.XMLObject is distinguished, because XMLObject provides its method original or corresponding XML of retrieving as the XML type for each XBean.XBean can be considered to be used for the Design Mode of the java class type of expression data (for example business datum), and these data can serializings and gone sequence to turn to XML, and can visit in the mode of type safety from Java.XBean can also be considered to a phrasal smaller subset of natural language, is Java or non-Java through note, is used to generate these types.Usually, when how the decision of application developer or component developer represents business datum, exist one compromise.If these data are expressed as the Java of type safety, then are difficult to sequence and turn to XML or database.If data are expressed as XML, then be difficult to be converted to the java class type.If data are bearing fruit concentratedly from of database, then for being converted to any one other type, there is same situation.Therefore, advantageously provide the java class type of single kind, it can transmit easily, use and operate as XML and Java.The favourable same type that also has is convenient to database access and form input and checking.
As shown in Figure 2, XBean in one embodiment can be in the point of crossing of three kinds of business datums: XML data 105, Java data 106 and database 107.XBean can only comprise data, and any logical OR method that is not used in communication or calculates.Can be with any one defines XBean in a plurality of idioms.In case defined XBean, then this XBean can be used for various linguistic context.For example, can use the XML pattern to define XBean, carry out instantiation by this XBean is appended to the XML inlet flow then.Like this, can distribute the java class type of generation and be used as a Javabean with friendly getter and setter.
For example, application developer can define the file of Mydata.schemabean by name, has following content:
<xsd:element?name="maData">
<xsd:sequence>
<xsd:element?name="a"type="xsd:string">
<xsd:element?name="i"type="xsd:int">
</xsd:sequence>
</xsd:element>
This document can be compiled as the XBean with metadata, as shown in Figure 4, illustrates based on the format sample of explaining, and this can be an another kind of mode of expressing XBean.
For example, if these data are once towards XML, before then the user may be concerned about that title still was described in title before describing.System and a method according to the invention allows the user to fetch original orderly XML.May there be any one method, the method for getXMLCursor for example by name and executeXPath based on the XMLObject type.The XML type can have a plurality of XML data manipulations, comprises and uses the XPath Query Value, uses the XQuery conversion value, or with XMLCursor iteration on data file.This fundamental type can be brought together several technology.
Some method can in time be determined the appearance of XML at any point.For example, the XML type can be used to implement to carry out the Web service of solicit operation, as shown in Figure 5.Code sample in the figure can be used for fixing the quantity in the whole purchase order.In the 1-2 of Fig. 5 was capable, this method was declared to adopting the Web service operation of PurchaseOrder XML type.Can discern the XML type during this Web service operation, and effectively transmit input information, and need not complete Analysis of X ML.The another kind of XML type of declaring in this pattern is LineItem, is the array of emptyItems by name as can be seen in 4,5,7 row.Because the XML type of compiling is a strong typing, so their permit to confirm two patterns, for example confirm that at schema file PurchaseOrder and Java compiler check, for example verify emptyItems[i] types of variables of .setQty (1) is integer.
For example, the user may receive a plurality of purchase orders, and it has and a plurality ofly with quantity 0 this line item purpose is set mistakenly and arranges project.The user may wish to handle these purchase orders, and no matter when make has people's amount field to be set to 0, then this system just this amount field be set to 1.Function can be with purchase order XBean as input, and can carry out XPath to this purchase order, any arrangement project mark under its inquiry purchase order mark, that quantity equals 0.This is the 5th row beginning from Fig. 5 for example.Can return to the user with the node listing of this XPath coupling.This node listing can be reduced to the XBean type that the user knows.The arrangement project set into array is selected to throw by this system.In case obtain the result by XPath, just can carry out iteration, and come the result of manipulation node with the XBean method by this result.
The Java accessor of strong typing may be not suitable for all XML and use.In one embodiment, the XML type can be expanded provides XPath, XQuery, and the basic side of XMLCursor and XMLReader is to the XMLObject of XML type.At the 5th row, XMLObject getAllValues method is carried out XPath to input, to find the arrangement item elements of all qty=0.At the 6th row and the 7th row, the LineItem type can be used to upgrade the XML data file as can be seen.Each example of the type is all represented a specific node in this document, and when the method called such as setQty (1), handles the data of this document in mode convenient, type safety.At eighth row, the type is directly returned from Web service, to finish this function and to send response message.
Can also handle conversion between the different XML types according to the system and method for the embodiment of the invention, wherein the user may need to handle XBean and comes retrieve data.For example, may need by illustrating and price changes to item id and mates the arrangement project of removing.This can finish by each directory entry of inquiry in existing application data base in one embodiment.This work can utilize the Java querying method that adopts integer project id and return the CatalogItem type to finish.For example:
CatalogItem?findCatalogItem(int?catalogID);
class?CatalogItem
{
int?getCatalogIDO;
String?getDescriptionO;
float?getPriceO;
}
Such and LineItem XML class types seemingly but have some more less important differences.For example, CatalogItem does not have quantity, item id catalogID by name rather than itemID.In fact, because CatalogItem and LineItem are closely similar, therefore wish to write in some cases all codes as shown in Figure 6.In Fig. 6, compound XML type, be that the value of LineItems is set to compound java class type, i.e. CatalogItem.Each XML type all has the method to set up that can adopt any type, thereby above-mentioned code can compile and move.But when operation, it is unexpected that the user may obtain the XML conversion, complains " the definition conversion is not mapped to LineItem from CatalogItem ".In this case, the user can select appropriate C atalogItem typonym and check corresponding XML conversion.If the user has a queried for items title and returns the existing bean of the java class type of CatalogItem by name, then CatalogItem will have the catalogID explanation of the line item of seeming, but slightly different with previous example.For example, do not have amount field, and the front be called itemID be called catalogID now.
In the system and method according to the embodiment of the invention, each XML conversion can adopt the XQuery that is stored in the conversion catalogue to realize.Each XQuery can be a particular type from one or more type conversion with known XML pattern.Can adopt the visual XQuery editing machine of default type with the input and output type that is restricted to the line item type and CatalogItem.The XQuery editing machine is permitted system or the user is connected itemID with catalogID, and shows that this quantity should be 0.
Fig. 7 illustrates the example of the default type statement of CatalogItem class.This statement can be written in the file that comprises all conversion list by XQuery.Can define the XQuery that tells system how directory entry to be converted to the conventional spread item.The example of this inquiry is shown in Figure 8.Bold text among Fig. 8 is corresponding to catalogID being mapped as itemID and extra field qty is set to 0 XQuery.Remaining is that this XQuery is contained in shell in the XML file.This 0 value can be repaired, and for example finishes in Java shown in Figure 9.At the 13rd row of Fig. 9, can see that directory entry is sent to the code sample of item line.The directory entry that may expect to adopt the user from existing API, to obtain, and with this directory entry put into will the expression line item XBean.This code can not work usually, because directory entry is different with line item.
The example of XML converting system is shown in Figure 10.In one embodiment, the overall situation of conversion (XQuery) record 111 can be used for from a kind of data type to another kind of data type.In case obtain the subclass of XQuery, converting system 110 just can inquire about whether there is from Source Type 108 to target type 109 conversion automatically.In another embodiment, still can use transformation warehouse 112, but be converted to target type from Source Type automatically, a title is all given in each conversion.When the line item of given directory entry and routine need be provided with, the user for example woke conversion up with title simply before setting is waken up.13 and 14 row that boldface type is represented in Fig. 9 tell system directory entry to be converted to the function call of line item existence between set and findCatalogItem.A reason clarifying this conversion is that sightless conversion record may be too abstract concerning a lot of users, and " cannot see ".If the user allows data be converted, then this user may wish in fact to see the title of conversion in code.If the user can see this title, then this user can browse in code to determine that what conversion has influenced data and how to have influenced these data.This can be a kind of inspection, so the user can be sure of that this conversion is understood, and no matter this code belongs to this user still is other people.
Another kind guarantees that quantity is that correct mode is by line item conversion definition CatalogItem, to adopt two input variables, as CatalogItem and integer amount.From this example, as can be seen, exist the overall situation of changing to write down and represent Source Type and target type.Source and target can be the java class type.When needing to translate automatically between dissimilar for two, will inquire about this record.Can use and allow a java class type according to circumstances to be mapped as the record of any a plurality of different XML types.Record also has the advantage that the each mapping between any two given types only need define once, can re-use easily then.
In some system, such difficulty may appear, may need in a program, to handle simultaneously a kind of a plurality of versions of pattern.For this reason, can stipulate that each pattern all wants version identifier of mark.Relevant java class type and conversion can separate processes, each version all are used as the type system of oneself.
In another example, the user may wish to write with the Web service of directory entry as input, or wishes to expose such as the existing Java function of findCatalogItem to be Web service.For example, can write following code comes in existing system findCatalogItem exposed and is Web service:
class?MyWebService
{
/**@jws:operation*/
CatalogItem?findCatalogItem(int?catalogID)
{
return?MyDbUtilities.findCatalogItem(catalogID);
}
}
When being applicable to the WSDL type of this Web service, user definition can accept this method.Unfortunately, this situation may be to have the existing xml schema of describing the expected result type.For example, the possibility of result returns as the purchase order line item element of standard, as shown in above-mentioned example.In this case, Shi Ji WSDL may be inconsistent with existing XML pattern.Can attempt to create the appropriate mode that adopts the XML conversion, but not provide grammer easily, existing system is helpless to guarantee that this mapping is consistent with this pattern.But, if employing can be easy to then guarantee that according to the conversion record of various embodiments of the present invention return results is consistent with adequate types.
For example, this code can be revised as follows:
class?MyWebService
{
/**
*@jws:operation
*@jws:return-schema?type="po:line-item"
*/
CatalogItem?findCatalogItem(int?catalogID)
{
return?MyDbUtilities.findCatalogItem(catalogID);
}
}
That above-mentioned code requires to exist is defined, the CatalogItem type is mapped as the XML conversion of the type of po:line-item element.If no, then IDE circulates a notice of a mistake on the backtrack mode note.But if there is the conversion of definition, the return type of then Web service method can be consistent with the pattern that requires, and the pattern that needs can be included among the WSDL of transmission.
In this embodiment, in the row that comprises return-shema type=po:line-item, system permits user's Returning catalogue item, but has line item in XML.This system can jump to the record of XQuery and carry out and use the instruction of knowing XQuery.This embodiment provides the related of XQuery and XML mapping, to the support of each pattern and the strong typing view of visit data and the approach of XML view simultaneously.
As shown in figure 11, when the system and method according to an embodiment loaded one section XML as XML Class1 14, this XML type can be loaded in the light inside XML storer 115.This is similar to the thing that can make of W3C document dbject model (DOM), just finishes in more convenient mode, and this can faithful to fully original XML.This storer is very light because it only comprise XML data 113 as the index that can search for or in current example approximate text or the tag level of being in.Therefore, when the user had XML type such as purchase order, this user can only have the handle that points to one of them light XML storage address, and this can be similar to the XML tree.When the user obtains to quote, may be also without any arrangement.When the user calls method such as getLineItem, getLineItem.getDesc or getQty, can call getter, this getter is used for arranging, determining type and echo reply.This method is saved time very much, because only handle a part of data.
System and method according to some embodiment can keep XML pattern and corresponding java class type synchronously.The user who for example has strong typing Java can begin to add new line item or change quantity.If this user wishes operation XPath path on the java class type then, then this XPath may move by the current format with these data on the XML data file.In this case, if the user aspect XML or the Java aspect of strong typing change file, then can make suitable partial invalidity on the other hand.When the user checks that this on the other hand subsequently, can find out the problem that before had been disabled information.
In order to compile the XML pattern, may need to analyze this pattern or XSD file, this is called " pattern is pattern (schema for schema) ", in other words, is the XSD file that representative is applicable to the pattern of XSD file itself.If system supposition can 100% handled the pattern that passes to this system, and this system produces Java accessibility easily, expects that then this system uses the generation type of oneself to understand the XSD file when read mode.The user should the employing pattern be pattern and be compiled among the Java, thereby makes system only use Java.
As shown in figure 12,, can there be two parts and arbitrary data piece at least according to the system and method for some embodiment, or the XML data, comprise the legal type of data 116 and the implication of raw data 119.It is effective which kind of data of legal type definition of data are considered to current application.Pattern can comprise the very concrete details that relates to the legal type of data, can also comprise the details that relates to the data implication in some cases.In case the legal type of given data then can generate in the strong typing mode automatic type to this data access is provided.This part is because this pattern can be discerned all effective son fields of given data field.Can give the Java visit of strong typing then at correct position to the user.Even the user load these data and make these data in adequate types after, this user may still not know the implication of these data.In this case, can adopt the pattern compiler 117 of understanding this raw data.It is similar to the compiler that is called compiler a bit, and as YACC (compiler of another compiler), they can adopt abstract grammar and this abstract grammar is compiled in the syntax tree.Because XML has been a syntax tree, so this is not a problem.But XML is not affined syntax tree.In this tree, any node can have a lot of elements under it.In case the user has the pattern that possibility is considered to the XML grammer, then this user just clearly knows the thing of being supposed under any given node.Therefore, replace and use original XML syntax tree, the user can utilize the advantage of the syntax tree that is subjected to schema constrains.
System and method according to the embodiment of the invention remains the java class type with each pattern, comprises simple types.If the pattern that the user has is limited simple types, then can in this pattern, show.For example, if the user-defined type this legal type that is integer, it must be 5 bit digital between 10000-99000.Be defined as the simple integer type need not to resemble in existing system.On the contrary, this information can produce in the java class type.The title of java class type can generate with this pattern, for example title " limited integer ".
The another kind distortion that is kept by system and a method according to the invention appears in the pattern and exists under the situation of at least two types as fundamental type.If one of them type is another fundamental type, then this pass ties up to and connects these two types among the Java.The translation of the height loyalty of type system allows fundamental type to be kept.
Whether effective engine of the XML type constraint 118 of use compiling can also be used to permit the user and determine according to the relevant arbitrarily XML Class1 20 of this XML effective.For example, the purchase order line item may have explanation quantity, catalog number (Cat.No.) and price in XML.Can also limit suitable XML pattern, indicate that promptly " explanation " is optionally, and catalogItemNumber not be optional.In Java, can't show that a field is not optionally, maybe can not be empty.Like this, the most of people that arrange can not verify beans (bean).Can use according to the embodiment of the invention, permit the user and retrain the verification method of verifying any bean and being apprised of any validity problem at the XML type.
In system and method, can in a plurality of Java assemblies, share the XML type according to some embodiment.XBean can send automatically, for example plays a role in the place of the XML type that generates automatically for user-defined component definition.In this case, the XBean of representation parameter and rreturn value can be used as inner classes and is generated to automatically on the XML control interface that generates into this assembly.If in fact share type of message between a lot of assemblies, each example that then makes privately owned XBean type be used for this message may be nonsensical.In this case, should when the user-defined assembly of definition, clearly point out an Xbean type, how be shared so that clearly control the XML type of this assembly.For example:
package?mypackage;
/**
*@jws:xml-interface?enable="true"
*/
class?MyComponent
{
/**
*@jws:operation
*parameter-xml-type="MyData"
*return-xml-type="MyStringMessage"
*/
String?myOperation(String?a,inti){return?a+i;}
}
By in this assembly for example for parameter x ml quotes XBean type MyData, it can be asserted that this bean has the getter corresponding to the independent variable name.For example, getA should return a String, and getI should return an int.If these types are not arranged, then may cause compile-time error.For returning xml, it can be asserted that this bean type is a rreturn value, or it has the single characteristic of type and rreturn value coupling.XML type has by reference been quoted the XML pattern of the input and output type of message that defines this method.This pattern can reuse, because they have the title such as MyData.Mapping also can be quoted between XML and java class type.This mapping can be used as metadata and adds the MyData type to, because it is to add named type to, this mapping can reuse.
The generation XML control interface that obtains in the time of can specifying explicit XBean on assembly is as follows:
package?mypackage;
interface?MyComponentXMLControl
{
/**
*@jws:return-xml?xml-type="MyStringResult"
*@jws:parameter-xml?xml-type="MyData"
*/
XML?myOperation(XMLx);
}
In this embodiment, the XBean type of name is used to specify the xml pattern of permission, does not generate inner classes.
The XBean type can be expanded basic XML type, thereby XBean also can be transmitted in the place that makes it possible to transmit XML.In addition, any XBean can both append to the XML data file, and XBean also can be created for convenience of these data of accessing in the place that therefore can obtain XML.In system and method, can easily create XBean and use in several different modes according to some embodiment.For example, can imply by definition JWS (Java Web service) method and create XBean.Can create XBean with the mapping related based on this function parameters tabulation with this function.Can also utilize * .xbean file to come explicitly to create XBean.Have at least two kinds of diverse ways to realize * .xbean file, as JavaBean+Maps or XML+Query, each can both freely use note.The implicit example of creating bean may be as follows in the JWS operation:
/**
*@jws:operation
*@jws:usebean?beanName::creditCardInfo::
**/
updateCreditCardInfo(String?custId,String?ccNumber,Date?expDate,Address?addr)
XBean is impliedly created in this acquiescence mapping of using this operation.These that mapped specific is used for that this operation uses input and output shine upon creates XBean.If defined beanName, then can use existing bean.Can use independent grammer when creating bean, rather than use existing grammer.
A simple JavaBean+Maps*.xbean file is as follows:
{
/**
*@xbean:property
**/
String?name;
/**
*@xbean:property
**/
String?address;
}
This can create the file with public get and set method, and is the standard x ML of this feature set definition.The file of more complicated has additional mapping, as:
public?interface?xbeanl?extends?JavaXBean
{
/**
*@jws:inputxml?xml-map::
*<PERSON><NAME>{name}</NAME><ADDRESS>{address}</ADDRESS>::
**/
/**
*@xbean:property
**/
String?name;
/**
*@xbean:property
**/
String?address;
}
Above-mentioned example is used as local storage with single Java member.It is also important that can be with XML as local storage.On the contrary, a simple files can use XQuery to come rreturn value, and is as follows:
public?interface?xbean1?extends?XML?XBean
{
private?XML?xml;
void?xbeanl(XML?xmlParam)
{
xml=xmlParam;
}
/**
*@jws:xquery?statement::$xml/name/text()::
**/
String?getName();
}
In system and method, can there be two kinds of XML types: with the removable cursor of developer's viewpoint and can not movement value according to some embodiment.When moving cursor, can change by the XML data file portion of cursor navigation, so type can be designed as in the XML data file and operates Anywhere.On the other hand, can not can be fixed on a place by movement value, so they can be the methods of the pattern match of data file portion strong typing, that quote with it.Figure 13 illustrates the example of this realization, and wherein XMLIndex121 represents removable value, and XMLCursor122 or 123 represents the removable cursor of bottom XML data.XMLCursor can not be used in the actual realization of strong XML type, but should be noted that purchase order interface 124 provides similar and referred among the bottom XMLIndex, promptly is that it is immovable.
Although the user can use and handle strongly-typed such as PurchaseOrder just as common java class type, may be embodied as direct visit and operation bottom XML data after the type.For example, be right after after a value is arranged on strongly-typed, can obtain same value with the cursor that any use XPath searches for same data set.
Model shown in Figure 13 is of great use when keeping, inquire about, handle and reusing the XML data file.Other the time, may need to flow output XML for disposable use, and need not to keep this data file.For these situations, can there be the XMLReader class, advance analyzer as XML.Each XMLValue object can be by adopting XMLReader with oneself stream output.The XMLIndex constructor that can also have loading and index XMLReader content.
Figure 14 illustrates the example class hierarchical diagram of XML type API.In the figure, formulate concrete time-like Rounded Box specified interface when square frame.The user who begins from file or original inlet flow can arrange XML with XMLParser, then the file of arranging with the XMLIndex index.Two concrete classes only are shown here, and these classes are to be used for the factory XML type, that implement all other interfaces.
The XML type can be added pattern in the java runtime model to.For example, each pattern can be compiled in the java class type when compiling.This pattern can comprise compound type and simple types.The basis and the simple types that can be used for being built in the XML pattern such as the precompile type of XMLString and XMLDate.XMLObject itself is corresponding to xsd: any type.To each pattern, can in the target class layering, generate the pointer resource in addition, be used for that all are had the mode map of given title to corresponding java class type title.
Permit a plurality of patterns and have identical XML title, can indicate different " XML territory " titles but have the dissimilar of same names.Only allowing a territory is default domain.A kind of approach that control types generates is by the .xval file contiguous with the .xsd file when compiling.When operation, indexed XML can recognize pattern automatically.The visuality of pattern and current C lassLoader link together.The thread local index that can keep visualization model.When passing through qualified fully new model of XML title request, can call ClassLoader.getResourceAsStream and be used for for example finding the pointer that points to corresponding java class type at default domain.Also can carry out the inquiry in special domain.The realization of XMLIndex can be decomposed into all XML the type of this pattern of use automatically.If do not specify in " XML territory ", then can use default domain.Can also refer to fix other optional aspect of being permitted to use the different editions pattern.
Can adopt the traditional general or special number computing machine or the microprocessor of the religious doctrine programming according to the present invention to realize an embodiment, this technician to computer realm is conspicuous.The programming personnel is easy to prepare suitable software based on religious doctrine of the present invention, and this technician to software field is conspicuous.The present invention can also realize that this will be readily apparent to persons skilled in the art by prepared integrated circuit or by the suitable networks of building the traditional components circuit.
An embodiment comprises computer program, and it is a storage medium, has the instruction that is stored thereon/be used for computer programming to carry out in this arbitrary feature that presents.Storage medium can include but are not limited to the dish of any type, comprises floppy disk, CD, DVD, CD-ROM, microdrive and magneto-optic disk, ROM, RAM, EPROM, EEPROM, DRAM, VRAM, flash memory device, magnetic or optical card, minimum system (comprising molecule storage IC) or is suitable for the medium or the device of any type of storage instruction and/or data.
Be stored on any one computer-readable medium, the present invention includes and be used to control the hardware of general/special computers or microprocessor and make this computing machine or microprocessor to utilize result's of the present invention mechanical mutual software with people or other.This software can include but are not limited to device driver, operating system, execution environments/containers and application program.
The foregoing description of the preferred embodiments of the present invention is for illustration purpose, be not limit or limit the invention to disclosed definite form.Those skilled in the art can carry out many modifications and variations.Particularly, though notion " type " is used for XML and Java in the embodiment of said system and method, clearly, this notion also can be used with equivalent concepts interchangeably, as interface, form, class, object, bean and other suitable notion.Selecting and describing embodiment is for the best description the present invention and the principle of practical application thereof, makes other technician can understand the present invention thus, and various embodiment and embodiment with various modifications that are applicable to special applications are in the contemplation.Scope of the present invention is limited by claim and equivalent thereof.
Claims (66)
1. between XML and Java, arrange the system that conciliates array data for one kind, comprising:
The XML data;
The XML pattern of definition XML data;
The XML type, it is the java class type that can visit the XML data in Java; And
Can generate the compiler of XML type from the XML pattern.
2. system according to claim 1, wherein:
Described compiler can generate the XML type based on the definition of Java web services method.
3. system according to claim 1, wherein:
Described compiler can generate the XML type based on defined file.
4. system according to claim 1, wherein:
Described compiler can be compiled into the Java scheme one or more conventional java class types.
5. system according to claim 1, wherein:
Described XML type can be removable cursor, can read in any place in the XML data.
6. system according to claim 1, wherein:
Described XML type can be can not movement value, can quote the fixed part of XML data.
7. system according to claim 1, wherein:
Described XML type can be shared between a plurality of Java assemblies.
8. system according to claim 1, wherein:
Described XML type can be upgraded the XML data in Java.
9. system according to claim 1, wherein:
Described XML type can be used java class type method to visit and upgrade the Java data.
10. system according to claim 1, wherein:
Described XML type can be visited and new database more.
11. system according to claim 1, wherein:
Described XML type can be carried out a plurality of XML data manipulations, comprising: the Query XML data, between the XML type conversion and in the enterprising row iteration of XML data file.
12. system according to claim 1 also comprises:
Can define the XML pattern of the legal type of XML data, this legal type comprises the constraint to data type and data area; And
Constraint to data type and XML type scope.
13. system according to claim 12, wherein:
Described compiler can be by the constraint that generates the XML type about the XML pattern of the legal type of XML data.
14. system according to claim 12, wherein:
Described constraint to the XML type can be verified this XML type.
15. the system of a translation type between XML and Java comprises:
The java class type;
The XML type, it is the java class type that can visit the XML data in Java; And
Source Type can be converted to the XML conversion of target type, wherein said Source Type and target type can be XML type or java class type.
16. system according to claim 15 also comprises:
The existing XML conversion between Source Type and target type can be inquired about in the overall record of XML conversion.
17. system according to claim 15 also comprises:
The XML transformation warehouse can be inquired about existing XML conversion by title between Source Type and target type.
18. between XML and Java, arrange the system that conciliates array data, comprising for one kind:
The XML data;
The light XML storer that but the XML data can be kept as search index;
The XML type, it is the java class type that can quote this light XML storer and visit the XML data in Java.
19. between XML and Java, arrange the system that conciliates array data, comprising for one kind:
The XML data;
The XML data can be remained on the light XML storer of text or tag level;
The XML type, it is the java class type that can quote this light XML storer and visit the XML data in Java.
20. system according to claim 19, wherein:
Described light XML storer can be expressed as hierarchy with the XML data that keep.
21. system according to claim 20, wherein:
Described hierarchy can be a tree.
22. system according to claim 19, wherein:
Described XML type can increment accessing XML data.
23. one kind is used for arranging the method for conciliating array data between XML and Java, comprises:
With XML mode-definition XML data;
In Java, pass through XML type of access XML data; And
From the XML pattern, generate the XML type with compiler.
24. method according to claim 23 also comprises:
Definition based on Java web services method generates the XML type.
25. method according to claim 23 also comprises:
Generate the XML type based on defined file.
26. method according to claim 23 also comprises:
The Java scheme is compiled as one or more conventional java class types.
27. method according to claim 23 also comprises:
Come any place in the XML data to read as removable cursor described XML type.
28. method according to claim 23 also comprises:
With described XML type as the fixed part of can not movement value quoting the XML data.
29. method according to claim 23 also comprises:
Between a plurality of Java assemblies, share described XML type.
30. method according to claim 23 also comprises:
In Java, upgrade the XML data by described XML type.
31. method according to claim 23 also comprises:
Use java class type method to visit and upgrade the Java data.
32. method according to claim 23 also comprises:
Visit and new database more by described XML type.
33. method according to claim 23 also comprises:
Utilize a plurality of XML data manipulations by described XML type, these operations comprise: the Query XML data, between the XML type conversion and in the enterprising row iteration of XML data file.
34. method according to claim 23 also comprises:
By the legal type of XML mode-definition XML data, this legal type comprises the constraint to data type and XML data area.
35. method according to claim 34 also comprises:
By the constraint that generates data type and XML type scope about the XML pattern of the legal type of XML data.
36. method according to claim 34 also comprises:
Utilize described constraint to verify this XML type to the XML type.
37. the method for a translation type between XML and Java comprises:
Adopt the java class type;
Adopt the XML type, it is the java class type that can visit the XML data in Java; And
By the XML conversion Source Type is converted to target type, wherein said Source Type and target type can be XML type or java class type.
38., also comprise according to the described method of claim 37:
The existing XML conversion of overall record queries between Source Type and target type by the XML conversion.
39., also comprise according to the described method of claim 37:
Between Source Type and target type, inquire about existing XML conversion by the XML transformation warehouse with title.
40. between XML and Java, arrange the method for conciliating array data, comprising for one kind:
But the XML data are remained search index by light XML storer; And
In Java, quote this light XML storer and visit the XML data by the XML type.
41. between XML and Java, arrange the method for conciliating array data, comprising for one kind:
By light XML storer the XML data are remained on text or tag level;
In Java, quote this light XML storer and visit this XML data by the XML type.
42., also comprise according to the described method of claim 41:
The XML data that keep are expressed as hierarchy, and this hierarchy can be a tree.
43., also comprise according to the described method of claim 41:
By XML type increment accessing XML data.
44. a machine readable media of having stored instruction, it makes system when being carried out by processor:
With XML mode-definition XML data;
In Java, pass through XML type of access XML data; And
From the XML pattern, generate the XML type with compiler.
45. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
Definition based on Java web services method generates the XML type.
46. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
Generate the XML type based on defined file.
47. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
With compiler the Java scheme is compiled as one or more conventional java class types.
48. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
Come any place in the XML data to read as removable cursor described XML type.
49. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
With described XML type as the fixed part of can not movement value quoting the XML data.
50. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
Between a plurality of Java assemblies, share described XML type.
51. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
In Java, upgrade the XML data by described XML type.
52. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
Use conventional java class type method to visit and upgrade the Java data.
53. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
Visit and new database more by described XML type.
54. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
Utilize a plurality of XML data manipulations by described XML type, these operations comprise: the Query XML data, between the XML type conversion and in the enterprising row iteration of XML data file.
55. according to the described machine readable media of claim 44, also comprise instruction, make the system that when carrying out, allows:
By the legal type of XML mode-definition XML data, this legal type comprises the constraint to data type and XML data area.
56. according to the described machine readable media of claim 55, also comprise instruction, make the system that when carrying out, allows:
Use XML pattern about the legal type of XML data to generate constraint to the XML type.
57. according to the described machine readable media of claim 55, also comprise instruction, make the system that when carrying out, allows:
Utilize described constraint verifying XML type to the XML type.
58. a machine readable media of having stored instruction, it allows system when being carried out by processor:
Adopt the java class type;
Adopt the XML type, it is the java class type that can visit the XML data in Java; And
By the XML conversion Source Type is converted to target type, wherein said Source Type and target type can be XML type or java class type.
59. according to the described machine readable media of claim 58, also comprise instruction, make the system that when carrying out, allows:
The overall situation by the XML conversion is recorded in the existing XML conversion of inquiry between Source Type and the target type.
60. according to the described machine readable media of claim 58, also comprise instruction, make the system that when carrying out, allows:
Between Source Type and target type, inquire about existing XML conversion by the XML transformation warehouse with title.
61. a machine readable media of having stored instruction, it allows system when being carried out by processor:
But the XML data are remained search index by light XML storer; And
In Java, quote this light XML storer and visit the XML data by the XML type.
62. a machine readable media of having stored instruction, it allows system when being carried out by processor:
By light XML storer the XML data are remained on text or tag level; And
In Java, quote this light XML storer and visit this XML data by the XML type.
63., also comprise the system that when carrying out, allows that makes of instructing according to the described machine readable media of claim 62:
The XML data that keep are expressed as hierarchy, and described hierarchy can be a tree.
64. according to the described machine readable media of claim 62, also comprise instruction, make the system that when carrying out, allows:
By XML type increment accessing XML data.
65. between XML and Java, arrange the system that conciliates array data, comprising for one kind:
Device with XML mode-definition XML data;
In Java, pass through the device of XML type of access XML data; And
From the XML pattern, generate the device of XML type with compiler.
66. one kind is presented as the computer data signal in the transmission medium, comprises:
Comprise code segment with the instruction of XML mode-definition XML data;
Be included in the code segment that passes through the instruction of XML type of access XML data in the Java; And
Comprise the code segment that from the XML pattern, generates the instruction of XML type with compiler.
Applications Claiming Priority (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US44267303P | 2003-01-24 | 2003-01-24 | |
US60/442,673 | 2003-01-24 | ||
US10/762,814 | 2004-01-22 |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1799029A true CN1799029A (en) | 2006-07-05 |
CN100346304C CN100346304C (en) | 2007-10-31 |
Family
ID=36819238
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2004800027649A Expired - Lifetime CN100346304C (en) | 2003-01-24 | 2004-01-23 | XML types in java |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100346304C (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101470591B (en) * | 2007-12-29 | 2011-11-02 | 华为技术有限公司 | Method and apparatus for producting hyper text markup language code through Java service page label |
CN106133685A (en) * | 2014-03-27 | 2016-11-16 | 微软技术许可有限责任公司 | To the management based on layering instruction of behavior when running |
US10241784B2 (en) | 2014-03-27 | 2019-03-26 | Microsoft Technology Licensing, Llc | Hierarchical directives-based management of runtime behaviors |
CN110009950A (en) * | 2019-03-26 | 2019-07-12 | 乐佰科(深圳)教育科技有限公司 | A kind of online cooperative coding code synchronisation method and system |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20010029604A1 (en) * | 2001-04-27 | 2001-10-11 | Jacob Dreyband | Descriptive data construct mapping method and apparatus |
US7962925B2 (en) * | 2002-02-22 | 2011-06-14 | Oracle International Corporation | System and method for XML data binding |
-
2004
- 2004-01-23 CN CNB2004800027649A patent/CN100346304C/en not_active Expired - Lifetime
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101470591B (en) * | 2007-12-29 | 2011-11-02 | 华为技术有限公司 | Method and apparatus for producting hyper text markup language code through Java service page label |
CN106133685A (en) * | 2014-03-27 | 2016-11-16 | 微软技术许可有限责任公司 | To the management based on layering instruction of behavior when running |
US10241784B2 (en) | 2014-03-27 | 2019-03-26 | Microsoft Technology Licensing, Llc | Hierarchical directives-based management of runtime behaviors |
CN106133685B (en) * | 2014-03-27 | 2019-10-18 | 微软技术许可有限责任公司 | The management based on layering instruction of behavior when to operation |
CN110009950A (en) * | 2019-03-26 | 2019-07-12 | 乐佰科(深圳)教育科技有限公司 | A kind of online cooperative coding code synchronisation method and system |
CN110009950B (en) * | 2019-03-26 | 2021-05-18 | 乐佰科(深圳)教育科技有限公司 | Online cooperative coding code synchronization method and system |
Also Published As
Publication number | Publication date |
---|---|
CN100346304C (en) | 2007-10-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
World Wide Web Consortium | XSL transformations (XSLT) version 2.0 | |
CN1302398C (en) | Programming language extensions for processing data representation language objects and related applications | |
CN100559346C (en) | The system and method that is used for instantiating abstract class | |
AU2004208330B2 (en) | XML types in Java | |
US7076772B2 (en) | System and method for multi-language extensible compiler framework | |
US10509854B2 (en) | Annotation processing of computer files | |
US8180806B2 (en) | Mechanism for supporting indexed tagged content in a general purpose data store | |
CN1811766A (en) | Programmability for binding data | |
CN1573693A (en) | System and method for creating, managing and using code segments | |
CN1573753A (en) | Database object script generation method and system | |
CN1811702A (en) | System and method for developing portal applications and automatically deploying them into a portal server application | |
CN1688977A (en) | Intelligent use of user data to pre-emptively prevent execution of a query violating access controls | |
US20080033968A1 (en) | Methods and apparatus for input specialization | |
US8196121B2 (en) | Modular integration of distinct type systems for the compilation of programs | |
CN1228728C (en) | System and process for developing customized business report forms in the WEB applications | |
CN1729448A (en) | Transparent EJB support and horizontal data partitioning | |
US20070282894A1 (en) | Integration of external schemas and types into native programming languages | |
MXPA03004411A (en) | System and method for defining and using subclasses declaratively within markup. | |
CN100346304C (en) | XML types in java | |
Mu et al. | Specification of modelling languages in a flexible meta-model architecture | |
US7315980B2 (en) | Method and apparatus for generating electronic document definitions | |
EP2056222A1 (en) | Method for performing an operation on an XML database | |
US7934193B2 (en) | Processing a module specification to produce a module definition | |
US20030233373A1 (en) | Method, computer program product, and system for automatic class generation with simultaneous customization and interchange capability | |
WO2020027930A1 (en) | Property filtering |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
ASS | Succession or assignment of patent right |
Owner name: ORACLE INT CORP Free format text: FORMER OWNER: BEA SYSTEMS CORP. Effective date: 20110418 |
|
C41 | Transfer of patent application or patent right or utility model | ||
TR01 | Transfer of patent right |
Effective date of registration: 20110418 Address after: California, USA Patentee after: ORACLE INTERNATIONAL Corp. Address before: California, USA Patentee before: BEA SYSTEMS, Inc. |
|
CX01 | Expiry of patent term |
Granted publication date: 20071031 |
|
CX01 | Expiry of patent term |