ServingXML Element Reference

Daniel Parker

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Apache License, Version 2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Table of Contents

I. ServingXML Elements
II. Framework Elements
1. id ref Attributes
2. Configuration Elements
3. Resources and Service Elements
4. String Elements
5. Stream Source and Sink Elements
6. XML Content and Filter Elements
7. Record Mapping Elements
8. Inverse Record Mapping Elements
9. Record Readers, Writers and Filters
10. Flat File Record IO
11. SQL Record IO
III. Extension Elements
12. SUN Multi Schema Validator Extension
13. Apache FOP Extension
14. Java Mail Extension
15. EDT FTP Extension
Glossary
A. Data Type Mappings
B. Deprecated Elements and Attributes

Part I. ServingXML Elements

The index lists all the ServingXML elements in alphabetical order. The chapters group them by functional area.

B

batchedRecordWriter, sx:batchedRecordWriter
batchedSerializer, sx:batchedSerializer
batchRecords, sx:batchRecords
binaryField, sx:binaryField

E

elementMap, sx:elementMap
emptyDocument, sx:emptyDocument
expiryOptions, sx:expiryOptions

F

fieldAttributeMap, sx:fieldAttributeMap
fieldDelimiter, sx:fieldDelimiter
fieldElementMap, sx:fieldElementMap
fieldElementSequenceMap, sx:fieldElementSequenceMap
fieldRestriction, sx:fieldRestriction
fileSink, sx:fileSink
fileSource, sx:fileSource
filter, sx:filter
flatFile, sx:flatFile
flatFileBody, sx:flatFileBody
flatFileHeader, sx:flatFileHeader
flatFileReader, sx:flatFileReader
flatFileSignature, sx:flatFileSignature
flatFileTrailer, sx:flatFileTrailer
flatFileWriter, sx:flatFileWriter
flatRecordField, sx:flatRecordField
flatRecordType, sx:flatRecordType
flatRecordTypeChoice, sx:flatRecordTypeChoice
flattenSubtree, sx:flattenSubtree
foEmitter, fop:foEmitter (deprecated - aliased to fop:foSerializer, use that element instead)
formatDateTime, sx:formatDateTime
foSerializer, fop:foSerializer
ftpClient, edt:ftpClient
ftpDirectoryReader, edt:ftpDirectoryReader
ftpSink, edt:ftpSink
ftpSource, edt:ftpSource

G

groupBy, sx:groupBy
groupChoice, sx:groupChoice

I

include, sx:include
innerGroup, sx:innerGroup
insertContent, sx:insertContent
inverseRecordMapping, sx:inverseRecordMapping

J

jdbcConnectionPool, sx:jdbcConnectionPool

K

key, sx:key
keyField, sx:keyField

L

log, sx:log

N

newField, sx:newField
newRecord, sx:newRecord

O

onError, sx:onError
onRecord, sx:onRecord
onSubtree, sx:onSubtree
or, sx:or
otherwise, sx:otherwise
outerGroup, sx:outerGroup
outputProperty, sx:outputProperty

Q

quoteSymbol, sx:quoteSymbol

R

raiseError, sx:raiseError
recordAggregator, sx:recordAggregator (deprecated - replaced by sx:composeRecord)
recordContent, sx:recordContent
recordCriteria, sx:recordCriteria
recordDelimiter, sx:recordDelimiter
recordFilter, sx:recordFilter
recordMap, sx:recordMap
recordMapping, sx:recordMapping
recordReader, sx:recordReader
recordRestriction, sx:recordRestriction
recordStream, sx:recordStream
recordSubtreeMap, sx:recordSubtreeMap (deprecated - replaced by sx:transformRecord)
recordTee, sx:recordTee
recordTest, sx:recordTest (deprecated - replaced by sx:recordRestriction)
recordValidator, msv:recordValidator
recordWriter, sx:recordWriter
regexFieldCriteria, sx:regexFieldCriteria (deprecated - aliased to sx:fieldRestriction, use that element instead)
removeEmptyAttributes, sx:removeEmptyAttributes
removeEmptyElementFilter, sx:removeEmptyElementFilter (deprecated - aliased to sx:removeEmptyElements, use that element instead)
removeEmptyElements, sx:removeEmptyElements
reorderRecords, sx:reorderRecords
repeatDelimiter, sx:repeatDelimiter
repeatingGroup, sx:repeatingGroup
repeatingSegment, sx:repeatingSegment (deprecated - use sx:repeatingGroup instead)
repeatingTaggedField, sx:repeatingTaggedField
replace, sx:replace
replaceRecord, sx:modifyRecord
replaceRecordFilter, sx:replaceRecordFilter
resources, sx:resources
restrictField, sx:restrictField (deprecated - aliased to sx:fieldRestriction, use that element instead)
restrictRecordFilter, sx:restrictRecordFilter
restrictRecordType, sx:restrictRecordType (deprecated - aliased to sx:recordRestriction, use that element instead), sx:restrictRecordType (deprecated - aliased to sx:recordRestriction, use that element instead)
runService, sx:runService

T

tagDelimiter, sx:tagDelimiter
taggedDelimitedField, sx:taggedDelimitedField
taggedFlatRecordField, sx:taggedFlatRecordField
tagTee, sx:tagTee
task, sx:task
toString, sx:toString
transform, sx:transform
transformerSettings, sx:xsltConfiguration
transformRecord, sx:transformRecord

U

urlSource, sx:urlSource

Part II. Framework Elements

Chapter 1. id ref Attributes

id ref Attributes

Attributes

NameRequiredValueDescription
idNoQNameAn identifier of an element instance. This id is the target for references by ref attributes.
refNoQNameThis attribute is used to reference an id.

The resources defined in a resources script may be given ids and referred to by reference, as shown below.

Figure 1.1. SAX pipeline with references


<sx:resources xmlns:sx="http://www.servingxml.com/core">
  <sx:service id="myPipeline">
    <sx:serialize>
      <sx:transform>
        <sx:filter ref="myPreFilter"/>
        <sx:filter ref="myFilter"/>     
        <sx:filter ref="myPostFilter"/>     
      </sx:transform>
    </sx:serialize>
  </sx:service>
  
  <sx:saxFilter id="myPreFilter" class="PreFilter"/>
  <sx:xslt id="myFilter">
    <sx:urlSource url="filter.xsl"/>
  </sx:xslt>
  <sx:saxFilter id="myPostFilter" class="PostFilter"/>     
</sx:resources>

Note that we could have written <sx:saxFilter ref="myPreFilter"/>, but instead we wrote <sx:filter ref="myPreFilter"/>, substituting the abstract component sx:filter for the derived sx:saxFilter. Identifiers given to components must be unique up to the abstract component level, for instance, a service and a filter may both be named "myPipeline", but a sx:saxFilter and a sx:xslt must be identified differently.

Chapter 2. Configuration Elements

sx:cacheSettings

Attributes

None.

Content

Optionally, any number of sx:property elements.

sx:expiryOptions

Attributes

NameRequiredValueDescription
revalidateNostring A list of revalidation codes with possible values "synch" or "asynch" (or both), or "full" or "none".

Content

None.

sx:patternMatcher

Attributes

NameRequiredValueDescription
classYesJava classAn implementation of the com.servingxml.components.regex.PatternMatcher interface.

Content

None.

sx:xsltConfiguration

Attributes

NameRequiredValueDescription
versionNoXSLT versionThe value of the XSLT version attribute appearing in generated stylesheets. Defaults to "1.0"

Content

Optionally, any number of sx:outputProperty elements.

Optionally, any number of sx:systemProperty elements.

Chapter 3. Resources and Service Elements

sx:defaultValue

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
valueNoSubstitutionExprA string value that may contain a parameter inside curly braces, e.g. "{$my-param}.xml".
selectNoXPath expressionAn XPath expression evaluated against the default XML document.

Content

  • Optionally, free form text.
  • Or, any number of sx:string elements.

Description

The sx:defaultValue element is used in a sx:parameter element to define a default value for a parameter.

The default value may be specified either by a value attribute or by the content. This value is only a default value, and if a run-time parameter is passed with the same name, the run-time value will be used in place of the default value.

See also

Examples

Example 3.1. Example of initializing a parameter to a constant.


  <sx:parameter name="validate"><sx:defaultValue>yes</sx:defaultValue></sx:parameter>


sx:include

Attributes

NameRequiredValueDescription
hrefYesURIA URI identifying a resources script.

Content

None.

sx:onError

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.

Content

One or more action elements from the following list.

Examples

Example 3.2. Apply a stylesheet to a fault raised in the book-order document handler.


  <sx:service id="post-book-order">
    <sx:serialize>
      <sx:transform>
         <sx:content ref="myns:book-order"/>
         <sx:xslt ref="myns:confirm-order"/>
      </sx:transform>
      <sx:onError>
        <sx:transform>
          <sx:xslt ref="myns:book-order"/>
        </sx:transform>
      </sx:onError>
    </sx:serialize>
  </sx:service>


sx:parameter

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
nameYesQNameThe name of the parameter.
valueNoSubstitutionExprA string value that may reference a parameter or field name inside curly braces, e.g. "{$my-param}.xml".
selectNoXPath expressionAn XPath expression evaluated against the default XML document.
typeNoXML Schema typesThe parameter value type. Defaults to xs:string The input parameter values will be converted to this type if required.

Content

Description

The sx:parameter element is used to define a parameter as a QName-value pair, for example,


  <sx:parameter name="validate">no</sx:parameter>

The value of the parameter may be specified either by a value attribute or by the content.

A parameter defined inside an element is visible to all siblings and all their descendents. It is not visible to ancestors. If the parameter has the same QName as a parameter in an ancestor, a new parameter value replaces the old one within the scope of siblings and descendents, but not in the scope of ancestors, the old value is still visible to ancestors. It is not possible to change the parameter value of an ancestor, changes are visible to siblings and descendents only. This is to avoid side effects.

The application processing the resources script may pass additional parameters to the script. For example, the console app may pass the parameter validate like this:


java -jar dir/servingxml.jar -r resources.xml myPipeline validate=yes
    < input.xml > output.xml

If you want to define a default value for the parameter, you must do so with a sx:defaultValue element as follows.


  <sx:parameter name="validate"><sx:defaultValue>no</sx:defaultValue></sx:parameter>

A passed parameter cannot override a parameter defined in a resources script unless the script's value is a default value, enclosed by a sx:defaultValue element. More generally, a parameter in an ancestor cannot override a parameter in a descendent unless the descendant's value is a default value.

Examples

Example 3.3. Example of initializing a parameter to a constant.


  <sx:parameter name="validate">yes</sx:parameter>


Example 3.4. Example of initializing a parameter with the output of a transformation.


  <sx:parameter name="myParam">
    <sx:serialize>
      <sx:transform>
        <sx:xslt> 
          <sx:urlSource url="styles/transform1.xsl"/> 
        </sx:xslt> 
        <sx:content ref="flat1"/>
      </sx:transform>
    </sx:serialize>
  </sx:parameter>


Example 3.5. Example of initializing a parameter using regular expression substitution on a record field called "name"


  <sx:parameter name="output-file-name">
    <sx:replace match="(books.*)[.]txt" replaceWith ="$1-new.txt"><sx:toString value="{name}"/></sx:replace>
  </sx:parameter>   


sx:property

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
keyYesStringDeprecated - use name instead.
nameYesStringThe custom property name.
valueYesStringThe custom property value.

Content

None.

sx:resources

Attributes

NameRequiredValueDescription
nsNoURIThe default namespace for the pages, documents, styles and serializers defined in this resources script.

Content

The list of elements that may be defined with a qualified name at the top level of the resources script includes all the elements that are defined in the sx:instructions section of the servingxml.xml configuration file. These include

sx:runService

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
serviceYesSubstitutionExprAn expression that evaluates to a QName identifying a service.

Content

Description

A sx:runService element is a task that invokes a service.

See also

sx:service

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.

Content

Examples

Example 3.6. Books page.


  <sx:service id="books">
    <sx:serialize>
      <sx:transform>
        <sx:content ref="myns:books"/>
        <sx:xslt ref="myns:books"/>
      </sx:transform>
    </sx:serialize>
  </sx:service>


sx:systemProperty

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
keyYesStringDeprecated - use name instead.
nameYesStringThe system property name.
valueYesStringThe value of a system property.

Content

None.

sx:task

Attributes

NameRequiredValueDescription
refYesQNameThis attribute is used to reference the id of a task.

Content

None.

Description

This is an abstract element that allows us to refer generically to any specialization of sx:task, such as sx:transform.

Examples

sx:raiseError

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.

Content

Description

A sx:raiseError element results in an exception being thrown. It is usually used inside an sx:onError element.

See also

Chapter 4. String Elements

sx:concat

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
separatorNocharA separator to separate each string value in the content.
quoteSymbolNocharA symbol to surround each string value.

Content

Any number of sx:string elements.

Description

sx:convertDate

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
fromFormatYesStringThe format of the input string, which must must follow the syntax specified for the JDK SimpleDateFormat class.
toFormatNoStringThe format of the output string, which must must follow the syntax specified for the JDK SimpleDateFormat class. Defaults to the date format for the default locale.

Content

An input string in the fromFormat, or a sx:string element that evaluates to an input string in the fromFormat. If the input string is empty, an empty (null) value is produced.

Description

sx:convertToDateTime

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
formatYesStringThe format of the input string, which must must follow the syntax specified for the JDK SimpleDateFormat class.
inputTimezoneYesStringThe format of the input string, which must must follow the syntax specified for the JDK SimpleDateFormat class.

Content

Lexical representation of one the eight XML Schema date/time datatypes, or an sx:string element that evaluates to a lexical representation. If the input string is empty, an empty (null) value is produced.

Description

sx:currentDate

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.

Content

None.

Description

The current date is output as a string with a lexical representation as defined for xs:date of XML Schema Part 2: Datatypes.

sx:currentDateTime

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.

Content

None.

Description

The current date is output as a string with a lexical representation as defined for xs:dateTime of XML Schema Part 2: Datatypes.

sx:currentTime

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.

Content

None.

Description

The current time is output as a string with a lexical representation as defined for xs:time of XML Schema Part 2: Datatypes.

sx:date (deprecated - replaced by sx:currentDateTime and sx:formatDateTime)

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
formatNoStringThe format of the output string, which must must follow the syntax specified for the JDK SimpleDateFormat class. Defaults to the date format for the default locale.

Content

None.

Description

sx:formatDateTime

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
formatNoStringThe format of the output string, which must must follow the syntax specified for the JDK SimpleDateFormat class. Defaults to the date format for the default locale.

Content

Lexical representation of one the eight XML Schema date/time datatypes, or an sx:string element that evaluates to a lexical representation.

Description

sx:replace

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
matchNoRegexMatch the entire input string against this pattern.
searchForNoRegexMatch sub-sequences of the input string against this pattern.
replaceWithYesStringReplace all matches with this expression. Dollar signs ($) may be used as references to captured subsequences in the match regular expression, and backslashes (\) may be used to escape literal characters.

Content

An input string, or a sx:string element that evaluates to an input string.

Description

The sx:replace element applies a regular expression to its content, and replaces matched content with a replacement string. The value of the regular expression may be defined either by the match attribute, which attempts to match the entire content, or by the searchFor attribute, which searches for all subsequences in the content that match the pattern

Examples

Example 4.1. Fix date.

In this example, you have an input record with a field service_from_date, which has the value


2005-06-28 00:00:00 

You want to change it to


20050628

You can make the replacement with the sx:replace element as follows.


  <sx:replace match="([0-9]{4})-([0-9]{2})-([0-9]{2})(.*)" replaceWith="$1$2$3">      
    <sx:toString value="{service_from_date}"/> 
  </sx:replace> 

Example 4.2. Remove commas from amount.

In this example, you have an input record with a field PLAN_IT_COST, which has the value


2,500,300.00

You want to change it to


2500300.00

You can make the replacement with the sx:replace element as follows.


  <sx:replace searchFor="," replaceWith ="">
    <sx:toString value="{PLAN_IT_COST}"/>
  </sx:replace>

sx:string

Attributes

NameRequiredValueDescription
refYesQNameThis attribute is used to reference the id of a string.

Content

None.

Description

This is an abstract element that allows us to refer generically to any specialization of sx:string, such as sx:toString.

sx:toString

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
valueNoSubstitutionExprA string value that may contain one or more parameters enclosed in curly braces, e.g. "{$my-param}.xml".
separatorNocharA separator to separate the pieces if the expression resolves to multiple values.
quoteSymbolNocharA symbol to surround the pieces. Deprecated, use a sx:quoteSymbol child element instead.

Content

Optionally, a sx:quoteSymbol element, to specify a quote symbol to surround the pieces making up the string.

Description

Chapter 5. Stream Source and Sink Elements

sx:defaultStreamSink

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
encodingNoStringA charset name. If a charset is not supplied, the default will be the charset of the default sink, e.g., the platform's default charset if the default sink is a flat file supplied to the command line app with the -o option.

Content

None.

See also

sx:defaultStreamSource

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
encodingNoStringA charset name. If an charset is not supplied, the default will be the charset of the default source, e.g., the platform's default charset if the default source is a flat file supplied to the command line app with the -i option.

Content

None.

See also

sx:fileSink

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
directoryNoSubstitutionExprAn optional directory name.
fileYesSubstitutionExprThe name of the output file, may contain parameters in the form {$myParam}.
encodingNoStringA charset name. If the output is XML, and a charset is not supplied, the XML serializer will use the last encoding encountered in the output properties of the transformation pipeline. If the output is a flat file, and a charset is not supplied, the default will be the platform's default charset.

Content

None.

Examples

Example 5.1. Example of file sink.


<sx:resources xmlns:sx="http://www.servingxml.com/core">
  
  <sx:service id="books">
    <sx:serialize>
      <sx:xsltSerializer>
        <sx:fileSink file="books.xml"/>
      </sx:xsltSerializer>
      <sx:transform>
        <sx:content ref="books"/>
      </sx:transform>
    </sx:serialize>
  </sx:service>
  
  <sx:document id="books">
    <sx:urlSource url="documents/books.xml"/>
  </sx:document>
  
</sx:resources>


See also

sx:fileSource

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
directoryNoSubstitutionExprAn optional directory name.
fileYesSubstitutionExprThe name of the input file, may contain parameters in the form {$myParam}.
encodingNoStringA charset name. If the input is XML, and a charset is not supplied, the XML parser will use the encoding specified by the XML declaration. If the input is a flat file, and a charset is not supplied, the default will be the platform's default charset.

Content

None.

Examples

Example 5.2. Example of file source.


<sx:resources xmlns:sx="http://www.servingxml.com/core">
  
  <sx:service id="books">
    <sx:serialize>
      <sx:transform>
        <sx:document>
          <sx:fileSource file="books.xml"/>
        </sx:document>
      </sx:transform>
    </sx:serialize>
  </sx:service>
  
</sx:resources>


See also

sx:streamSink

Attributes

NameRequiredValueDescription
refYesQNameThis attribute is used to reference the id of a stream sink.

Content

None.

Description

This is an abstract element that allows us to refer generically to any specialization of sx:streamSink, sx:fileSink.

Examples

sx:streamSource

Attributes

NameRequiredValueDescription
refNoQNameThis attribute is used to reference the id of a stream source.

Content

None.

Description

This is an abstract element that allows us to refer generically to any specialization of sx:streamSource, such as sx:fileSource.

Examples

sx:urlSource

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
urlYesSubstitutionExprThe name of the input url, may contain parameters in the form {$myParam}.
encodingNoStringA charset name. If the input is XML, and a charset is not supplied, the XML parser will use the encoding specified by the XML declaration. If the input is a flat file, and a charset is not supplied, the default will be the platform's default charset.

Content

None.

Examples

Example 5.3. Example of url source.


<sx:resources xmlns:sx="http://www.servingxml.com/core">
  
  <sx:service id="books">
    <sx:serialize>
      <sx:transform>
        <sx:document>
          <sx:urlSource url="books.xml"/>
        </sx:document>
      </sx:transform>
    </sx:serialize>
  </sx:service>
  
</sx:resources>


See also

Chapter 6. XML Content and Filter Elements

sx:attribute

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
attributeYesSubstitutionExpr The name of an attribute to insert into a parent element. The attribute name may contain a field name within curly braces, which will evaluate to the value of the field. The result must evaluate to a QName.
selectNoXPath expressionApply an XPath expression to the elements in the XML representation of a record that satisfy the conditon of the match pattern. The expression is evaluated as a string.
valueNoSubstitutionExprExpress the attribute value as a literal value, which may contain parameter names and field names enclosed in curly braces. The result must evaluate to a QName.

Content

Optionally, any number of sx:string elements. If present, these are used in place of the value and select attributes.

See also

sx:batchedSerializer

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.
pathYesSAXPath A SAXPath expression, which identifies subtrees.
batchSizeYesInteger The number of subtrees in a batch.
maxFilesNoInteger The maximum number of batch files.

Content

Examples

Example 6.1. Writing out countries XML with a maximum of 50 countries to a batch.


              
    <sx:serialize>
      <sx:transform>
        <sx:content ref="countries"/>
      </sx:transform>
      <sx:batchedSerializer path="country" batchSize="50">
        <sx:xsltSerializer>
          <sx:fileSink file="output/countries-{$sx:batchSequenceNumber}.xml"/>
        </sx:xsltSerializer>
      </sx:batchedSerializer>
    </sx:serialize>


sx:cachedContent

Attributes

NameRequiredValueDescription
id ref attributesNo Common id ref attributes.

Content

Content

Description

This element permits caching of XML content.

Attributes

None.

Content

See also

    sx:content

    Attributes

    NameRequiredValueDescription

    Content

    None.

    Description

    This is an abstract element that allows us to refer generically to any specialization of sx:content, such as sx:document.

    Examples

    Example 6.2. Using a sx:content element to refer to dynamic content.

    
    <sx:resources xmlns:sx="http://www.servingxml.com/core">
    
      <sx:service id="books">
        <sx:serialize>
          <sx:transform>
            <sx:content ref="books"/>
            <sx:xslt ref="books"/>
          </sx:transform>
        </sx:serialize>
      </sx:service>
    
      <sx:dynamicContent name="books" class="samples.books.BookCatalog">
        <sx:key>
          <sx:keyField name="category"/>
        </sx:key>
      </sx:dynamicContent>
    
    </sx:resources>
    
    

    sx:customEmitter (deprecated - aliased to sx:customSerializer, use that element instead)

    sx:customSerializer

    Attributes

    NameRequiredValueDescription
    id ref attributesNo Common id ref attributes.
    classYesJava ClassThe name of a Java class that implements com.servingxml.io.saxsink.SaxSink.

    Content

    Examples

    Example 6.3. Defining an Apache fop emitter.

    
      <sx:customSerializer id="fop-serializer"
                        class="com.servingxml.extensions.fop.xmlpipeline.FopEmitter">
      </sx:customSerializer>
    
    

    Example 6.4. Serializing an xsl-fo XML tree with an Apache fop serializer to produce pdf.

    
      <sx:service id="pulp">
        <sx:serialize>
          <sx:saxSink ref="myns:fop-serializer"/>
          <sx:transform>
            <sx:content ref="myns:pulp"/>
            <sx:xslt ref="myns:novel-fo"/>
          </sx:transform>
        </sx:serialize>
      </sx:service>
    
    

    sx:document

    Attributes

    NameRequiredValueDescription
    id ref attributesNo Common id ref attributes.

    Content

    • Optionally, a sx:streamSource element, or a sx:saxSource element, or an in-line XML document. Defaults to the default stream source, e.g. a file passed with the -i option on the command line.
    • Optionally, any number of sx:parameter elements.

    Examples

    Example 6.5. Defining a document with reference to an XML file.

    
    <sx:resources xmlns:sx="http://www.servingxml.com/core">
    
      <sx:document id="countries">
        <sx:urlSource url="documents/countries.xml"/>
      </sx:document>
    
    </sx:resources>
    
    

    sx:documentSequence

    Attributes

    NameRequiredValueDescription
    id ref attributesNo Common id ref attributes.
    wrapWithNoSubstitutionExprWrap all documents with this root element, defaults to "result".

    Content

    Description

    This instruction allows you to read a collection of XML documents on a file system as a sequence of documents wrapped with a root element. The results are streamed so that an arbitrarily large number of files may be processed.

    Examples

    Example 6.6. Defining a sequence of XML documents wrapped with the default root element "result".

    This example uses an sx:directoryReader element to read the names of the files in a directory called "data", and an sx:document element to load each of the files.

    
    <sx:documentSequence>
      <sx:directoryReader directory="data"/>
      <sx:document>
          <sx:fileSource directory="{parentDirectory}" file="{name}"/>
      </sx:document>
    </sx:documentSequence>
    
    

    Example 6.7. Defining a sequence of XML documents wrapped with the root element "documents".

    Note that an sx:recordStream element is also subtitutable for a sx:recordReader, which allows additional filtering on the contents of the file system. An sx:transform element is likewise subtitutable for a sx:content, which allows additional transformation and validation of the individual documents.

    
    <sx:documentSequence wrapWith="documents">
      <sx:recordStream>
        <sx:directoryReader directory="data"/>
        <sx:restrictRecordFilter>
          <sx:fieldRestriction field="name" pattern="countries.*[.]xml"/>
        </sx:restrictRecordFilter>
      </sx:recordStream>
      <sx:transform>
        <sx:document>
          <sx:fileSource directory="{parentDirectory}" file="{name}"/>
        </sx:document>
        <msv:schemaValidator>
          <sx:urlSource url="data/countries.xsd"/>
        </msv:schemaValidator>
      </sx:transform>
    </sx:documentSequence>
    
    

    See also

    sx:dynamicContent

    Attributes

    NameRequiredValueDescription
    id ref attributesNo Common id ref attributes.
    classYesJava ClassThe name of a Java class that implements com.servingxml.components.content.dynamic.RequestHandler and, optionally, com.servingxml.components.content.dynamic.Cacheable.

    Content

    Examples

    Example 6.8. Defining a document with reference to a Java class that simulates a SAX parser.

    
    <sx:resources xmlns:sx="http://www.servingxml.com/core">
    
      <sx:dynamicContent name="books" class="samples.books.BookCatalog">
        <sx:key>
          <sx:keyField name="category"/>
        </sx:key>
      </sx:dynamicContent>
    
    </sx:resources>
    
    

    sx:saxSink

    Attributes

    NameRequiredValueDescription
    refYesQNameThis attribute is used to reference an id.

    Content

    None.

    Description

    This is an abstract element that allows us to refer generically to any specialization of sx:saxSink e.g. sx:xsltSerializer.

    sx:emptyDocument

    Attributes

    NameRequiredValueDescription
    id ref attributesNo Common id ref attributes.

    Content

    None.

    Examples

    sx:filter

    Attributes

    NameRequiredValueDescription

    Content

    None.

    Description

    This is an abstract element that allows us to refer generically to any specialization of sx:filter, such as sx:xslt.

    Examples

    sx:key

    Attributes

    NameRequiredValueDescription
    id ref attributesNo Common id ref attributes.

    Content

    Examples

    See sx:dynamicContent.

    sx:keyField

    Attributes

    NameRequiredValueDescription
    id ref attributesNo Common id ref attributes.
    nameNoNameReference to the name of a parameter. On a request, t