Using XML and XSLT to Separate Content from Presentation XML as a Message Format for Business-to-Business Communication

XML Overview 2-7

2.8.1 Using XML and XSLT to Separate Content from Presentation

XML and XSLT are often used in applications that support multiple client types. For example, suppose you have a Web-based application that supports both browser-based clients and Wireless Application Protocol WAP clients. These clients understand different markup languages, HTML and Wireless Markup Language WML, respectively, but your application must deliver content that is appropriate for both. To accomplish this goal, you can write your application to first produce an XML document that represents the data it is sending to the client. Then the application can transform the XML document that represents the data into HTML or WML, depending on the clients browser type. Your application can determine the client browser type by examining the User-Agent request header of an HTTP request. Once the application knows the client browser type, it uses the appropriate XSLT style sheet to transform the document into the correct markup language. See the SnoopServlet example included in the examplesservlets directory of your WebLogic Server distribution for an example of how to access this type of header information. This method of rendering the same XML document using different markup languages in respective client types helps concentrate the effort required to support multiple client types into the development of the appropriate XSLT style sheets. Additionally, it allows your application to adapt to other clients types easily, if necessary. For additional information about XSLT, see Section A.5, Other XML Specifications and Information.

2.8.2 XML as a Message Format for Business-to-Business Communication

In a business-to-business B2B environment, Company A and Company B want to exchange information about e-commerce transactions in which both are involved. Company A is a major e-commerce site. Company B is a small affiliate that sells Company As products to a niche group of customers. When Company B sends customers to Company A, Company B is compensated in two ways: it receives, from Company A, both money and information about other customers that make the same sort of purchases as those made by the customers referred by Company B. To exchange information, Company A and Company B must agree on a data format for information that is machine readable and that operates with systems from both companies easily. XML is the logical data format to use in this scenario, but selecting this format is only the first step. The companies must then agree on the format of the XML messages to be exchanged. Because Company A has a one-to-many relationship with its affiliates, Company A must define the format of the XML messages that will be exchanged. To define the format of XML messages, or XML documents, Company A creates two document type definitions DTDs: one that describes the information that A will provide about customers and one that describes the information that A wants to receive about a newly affiliated company. Company B must also create two DTDs: one to process the XML documents received from Company A and one to prepare an XML document in a format that can be processed by Company A. 2-8 Programming XML for Oracle WebLogic Server 3 Developing XML Applications with WebLogic Server 3-1 3 Developing XML Applications with WebLogic Server The following sections describe how to use the Java programming language and WebLogic Server to develop XML applications. It is assumed that you know how to use Java Servlets and Java Server Pages JSPs to write Java applications. For information about how to write servlet and JSP applications, see Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server. ■ Section 3.1, Developing XML Applications: Main Steps