The adapter: URL Scheme

Stylus Studio uses URLs extensively to reach a variety of data sources. For example, if you use the built-in CSV adapter to open the three.txt file in the \examples\Adapters directory as an XML document, Stylus Studio builds the following URL:

adapter:CSV:newline=crlf:sep=,:first=yes:escape=\:quotes="'?file:///c:/Program Files/Stylus Studio XML Professional Suite/examples/Adapters/three.txt

The instructions to the adapter engine from this instance of the adapter URL are described in Table 148.

Instruction
Adapter URL String
Use the Comma-Separated Values adapter
adapter:csv
The line separator in the source file is a carriage return/line feed
newline=crlf
The column separator in the source file is a comma
sep=,
The values in the first row of the source file should be used to supply field names
first=yes
The escape character in the source file is a slash \
escape=\
The quote characters in the source file are " and '
quotes="'
The source file is three.txt
file:///c:/Program Files/Stylus Studio XML Professional Suite/examples/Adapters/three.txt
Table 148. Parts of an Adapter URL

While the basic format of the adapter URL is the same from one adapter to another, there are differences. For example:

  • Built-in adapters have different properties. You should always use Stylus Studio to build your adapter URLs to be sure that it uses valid properties and values. See Constructing Your Own Adapter URL for more information. For a complete description of properties for all adapters, see Adapter Properties.
  • The adapter: URL scheme can also be used to reference a user-defined converter (a .conv file). In this case, the adapter URL specifies only the location of the .conv file; the converter itself contains information about its property settings. An adapter URL that references a user-defined converter might look like this:

adapter:///myConverter.conv?file:inventory.txt

This adapter uses myConverter.conv to convert the file inventory.txt to some format (specified in the converter when you built it).

  • Property names in adapter URLs use an internal (generally, abbreviated) format, different from what is displayed in properties list in the Select XML Converter dialog box. Again, to avoid errors in your applications, use Stylus Studio to build your adapter URLs.

Adapter URL Syntax

While properties differ from one adapter to the next, the syntax used to invoke them is the same:

adapter:name :[property_name =value : | property_name =value : | ...]?file:file URL

Example:

adapter:Base64:newline=crlf:encoding=utf-8?file//w:\myfiles\base_to_xml.bin

In this example:

  • The name of the adapter is Base-64
  • Properties are newline and encoding
  • The file being converted is base_to_xml.bin on w:\myfiles

Where Adapter URLs are Displayed in Stylus Studio

Adapter URLs are displayed

  • In the Project window (select Show Full URL from the Project window shortcut menu)

Figure 507. Adapter URL Displayed in Project WIndow

  • In the URL field of the Select XML Converter dialog box, as shown in Figure 508.

Figure 508. Adapter URL Displayed in the Select XML Converter Dialog Box

You can use either source for the adapter URL strings in your Java applications. See Constructing Your Own Adapter URL for more information.

 
Free Stylus Studio XML Training:
W3C Member