Mais conteúdo relacionado
XML Transcoding
- 1. XML Transcoding
XML transcoding is the term used to describe the process of parsing and extracting XML data. The
XML transcoding technology is accessible through the DOM Browser which provides the developer
with superior source and target document visualization ensuring correct selection of the source node
(s) and placement into the target node—all through a point and click user interface. StableDOM—for
HTML transcoding—along with the XML and SQL data transcoding technologies may used together to
create an enterprise Mashup site. All of which are accessible through a point-and-click extraction
capability.
XML Transcoding Features
The XML transcoding technology provides the following major capabilities:
1. Parses XML content and provides a W3C XML DOM.
2. Enables XPath, XSLT, or XQuery access to the W3C XML DOM view.
3. Provides a high-level XML Transcoding Java API to access nodes based on an XPath query.
4. Provides a DOM Browser user interface enabling point-and-click extraction of XML element,
attribute, and text nodes.
5. Integrated with the XSLT/XQuery code generation component for transcoding from XML to
XHTML, WML, and other XML document types such as RSS.
6. Integrated with the portal code generation component for transcoding from multiple HTML
pages to XHTML and WML portlets based on the JSR 168 Portlet API (WSRP).
7. Supports URL and DOM caching for application specific cache management.
Standard XML Parsing Pipeline
The XML transcoding technology first parses the XML document and then a W3C DOM is made
available. The Xerces parser is the default XML parser.
This diagram presents a high-level view of the parsing pipeline:
Alternate XML Parsing Pipeline
In those cases where the source XML document is very large, the developer has the option to either
use our high performance Regex Element Finder or Pull Parser Component. Both of these
technologies are better suited to the memory demands and speed requirements needed to process
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 1
- 2. large XML documents. Both provide better loading/searching/filtering APIs than the classic SAX or
DOM parsers and APIs. Nonetheless, these APIs can return DOM nodes and are therefore fully
interoperable with downstream technologies such as XSLT.
For more information about the <alt> Pull Parse technology and some of its capabilities, please review
the product documentation for the Pull Parse Tool which leverages the underlying Pull Parse technology:
http://altmobile.com/pdf/Pull%20Parse%20Tool.pdf.
Accessing the W3C DOM
After completing the parsing and a W3C XML DOM is made available, you can access this DOM with 5
different technologies depending on your needs:
1. W3C XML DOM API.
2. XPath access through Jaxen.
3. XSLT access through Xalan.
4. XQuery access through Saxon.
5. XML Transcoding Java API which is based on common access patterns.
This diagram depicts the XML parsing pipeline and application access technologies:
Accessing the DOM with the XML Transcoding Java API
The XML Transcoding access API is implemented by the DOMUtil class in the package
com.altmobile.platform.util.xml.dom and provides the following method signature list:
1. static public String getContent (String urlString, String xpathString)
2. static public Node getNode (String urlString, String xpathString)
Accessing the DOM with the Transcoding XSL-Over-Java API
The XML Transcoding Java API may also be accessed from the user defined function mechanism
provide by the Xalan XSLT engine. There are two functions to extract XML content using XSLT. These
two functions were designed to mimic the XSLT “copy” pattern:
1. public static String getContent(String urlString, String xpathString)
2. public static Node getNode(String urlString, String xpathString)
The function getContent() will copy the text content of a node and getNode() will perform a
deep copy of the node.
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 2
- 3. The following screen shots highlight the user function declaration:
The function getContent() should be used with the <xslt:value-of> element and the
function getNode() should be used with the <xslt:copy-of> element.
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 3
- 4. Point-and-Click Extraction
Though the developer can manually type the code to perform the XML parsing and extraction using
languages such as XSLT or XQuery, the DOM Browser can automate this process with point-and-click
extraction and code generation.
As seen in this screen shot, the DOM Browser allows visual extraction:
The Transcoding Development Process
To transcode your XML into RSS, XHTML or WML, you should follow these steps:
1. Construct your target document in the DOM Browser, or load a valid XML document into the
DOM Browser. For example, using an RSS sample document as seen here:
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 4
- 5. We want to dynamically access a remote XML document and extract content and place it as the
child of the link element.
2. Decide which elements and text content should be extracted from the external XML
document.
3. Select the “Import Last Child from XML Source” menu item from the parent element of the
to-be-imported node as seen here:
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 5
- 6. 4. This will launch a new empty DOM Browser, allowing you to type the URL of the remote
document in the URL address field and extract a DOM element, an element’s text content, or
an attribute’s content as needed.
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 6
- 7. In the below screen capture, we want to extract the document_url element content:
To save space for this screen shot, we are abbreviating the text node content.
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 7
- 8. To learn more about the space-saving technologies of the DOM Browser, view its documentation at http://
altmobile.com/pdf/DOM%20Browser.pdf
After selecting the “Extract Node Value” menu item from the popup:
our target document will look like this:
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 8
- 9. To save space for this screen shot, we are abbreviating the text node content.
To learn more about the space-saving technologies of the DOM Browser, view its documentation at http://
altmobile.com/pdf/DOM%20Browser.pdf
5. Select the “Transform to Dynamic XSLT Source” menu item which cascades off the “XSLT”
menu item which is found in the document node popup menu as seen here:
This displays the Dynamic XSLT source code which contains instructions to create both the static RSS
and dynamic RSS using the special transcoding function getContent(url, xpath) as seen here:
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 9
- 10. Creating a Mashup or Web Portal through XML Transcoding
As mentioned before, the XML transcoding technology supports transcoding any element, attribute or
text value. As seen in the diagram below, you can transcode XML content from multiple documents:
In fact, you use the same development process to selectively transcode content from different
documents, HTML sites, and SQL databases. The only real-world limitation is the time it takes to
access the remote documents and the processing time needed in the parsing pipeline. URL and DOM
caches can reduce this time.
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 10
- 11. As we have seen, the code generation component can create an XSL document which uses the XSL-
over-Java API. We also provide a Java JSR 168 Portlet wrapper to the Dynamic XSL document. To
access this feature, select the “Java Code Generation” menu item and its “View As XSLT JSR-168
Portlet” sub-menu from the document node popup menu as seen here:
After prompting for an optional class name for the Portlet, the code generation component will
display two files. The first is the Portlet wrapper and the other is the Dynamic XSL document. As the
Portlet class will load the XSL file, ensure that you specify the correct path to the Dynamic XSL file as
determined by your Portlet engine.
© 2000-2007 ALT Mobile, LLC. XML Transcoding
<alt> XML Studio (TM) Version 6.0.0.122205a
http://altmobile.com 11