PI: importtxt
The purpose of an importtxt PI is to produce an XML-fragment
based on a (non-xml) text source
and replace the PI with this fragment.
The fragment may be a simple text node.
<?_wxt importtxt location="" code=""?>
The parameters are:
location (optional in templates) |
The URI of the file we want to import from.
In templates the location parameter is usually skipped.
In this case all content files (txtcontent) listed in the script
as direct children of the module are
searched for appropriate content.
You can reduce the search with parameter id, see below.
|
transformation (optional) |
A transformation identifier
(see:
Transformation
).
This transformation may have parameters:
T(name='ole' address='halden'). This transformation is applied before
we attempt to extract text. The transformation used here will normally
produce text.
|
id (optional) |
An id that match the id of the actual xmlimport
in script. Has only meaning when
this element has no location. One reason to use an id is
processing time if you have many contentfiles to a module.
Another reason may be that you have similar structures in different contentfiles and you
want to be selective.
|
|
The following parameters are optional and their purpose
is to extract and select from the text. |
leftpar (optional) |
A string that serves as left parenthesis of the text we want to extract
|
rightpar (optional) |
A string that serves as right parenthesis of the text we want to extract
|
select (optional) |
Will select which of the occurances of the marked (leftpar, rightpar)
textpieces we want to use. Default is all.
Possible values are: _all, _random,
commaseparated list of integers
or a "slice":
[a:b]-> [a..b>
[a:]-> [a..limit>
[:b]-> [0..b>
[:-b] [limit-b..limit>
|
replace (optional) |
Replaces text. We may have any number of replaces:
replace, replace1, replace2, etc.
The form is replace="out|in".
|
encoding (optional) |
The encoding of the text we import.
|
|
The following parameters make XML from the extracted text.
|
code (optional) |
Deprecated, use lang
The text will be colorcoded. Mainly used for programming languages.
Supported are: code,xmlcode,
javacode, javascriptcode, ccode, cppcode, csharpcode,
pythoncode, xsltcode, aspxcode, cs3code, htmlcode, csscode.
code should not be used together with parse.
|
lang (optional) |
The text will be colorcoded. Mainly used for programming languages.
The value of lang may be any value supported by the stylesheet and the involved javascript. The basic encoding is based on
Google's prettyprint. The module
Code Fragments
describes the setup and values supported..
When WXT prepares material with option preformat-language=yes, WXT's own colorencoding is used. This is mainly to
prepare for PDF. WXT's encoding supports the following codetypes:
- lang-j (java)
- lang-js (javascript)
- lang-c (c)
- lang-cpp (c++)
- lang-csh (c#)
- lang-css (Cascading Style Sheets)
- lang-xml (XML)
- lang-sql (SQL)
- lang-aspx (ASPX)
- lang-cs3 (actionscript)
- lang-mal (matlab)
- lang-py (python)
- lang (generic without colorencoding. All encoding defaults to this on failure on others)
|
parse (optional) |
If set to yes the extracted text is supposed to be
a XML-fragment and an attempt is done to parse it and
return it as a documentfragment.
parse is ignored if lang is set.
|
Examples:
<div>
<?_wxt importtxt location="jscase.js"
leftpar="//start"
rightpar="//stop"
lang="lang-js"?>
</div>