This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

need to translate codes in XML to user-friendly format


I am having a problem in translating reference data stored in an XML document to
user-friendly formats (I am taking the XML and translating it via server-side
XSL using Saxon into an HTML report)...for example, translating transaction type
code "15" into "Limit Order"


The short-form of the problem is that if I were to query a reference table in
the database, I could be making many hundreds of database calls per XSL
transform. If I were to store the XML reference data in a separate XML file, it
would probably be too large to manage (over 400,000 entries). I am looking for a
way, based on a particular XML document, to extract from a database reference
table (or other source) only those reference data items necessary for that
transform, and use that information in the XSL file.

The longer form of the problem is as follows:

In our application (Web-based, multi-client, server-side XSL processing), we are
capturing audit and history information in an XML string stored in a database.
The audit information looks something like:

<audit>
   <auditEntry date="12/15/1999">
      <field name="transactionTypeCode">
         <oldValue>15</oldValue>
         <newValue>18</newValue>
      </field>
   </auditEntry>
<audit>

The report being generated by XSL should read something like:

<html>...
The transaction type code changed from Limit Order to GTC Order
...</html>
having replace the values of 15 and 18.


The version information looks something like:
<trade>
     <order>
         <orderType>21</orderType>
         <client>1929219</client>
         ...
     </order>
     <transaction>
          <transactionType>38</transactionType>
          <counterParty>1029802</counterParty>
          <marketMaker>2343</marketMaker>
    </transaction>
</trade>

Likewise, all of these codes need to be translated, e.g. counterParty 1029802
would be displayed as "Just Another Brokerage Co."

This XML is stored in a table in the database as a string directly (our database
does not currently support XML internally). In the case of the audit, the user
asks to see all changes to the data from one date to another. The system queries
the database for all auditEntry xml fragments generated between those two dates
and wraps them in '<audit> /<audit>' tags. This XML is sent to the XSL
processor.

Unfortunately the process that stores the XML is not able to translate the codes
at that time to user-friendly formats.

I am currently doing this translation via a Java call from the XSL stylesheet,
which queries the reference tables in the database, and it works fine....just
that there may be hundreds of calls to make for a large XML document.

Similarly, if I were to use a SAX filter, I would have to make a separate call
for each field that needed translation.

What I want to do is extract from the XML all of the codes that need
translation, query the database once for the translation information, turn that
result set into an XML document and use that in the XSL for lookup purposes. The
reference XML might look like:

<refData>
     <field name="orderType">
          <code>15</code>
          <displayValue>Limit Order</displayValue>
     </field>
     ...
</refData>

I could store the full set of reference data in a static XML file (the data very
rarely changes) but as I stated before, that file could contain hundreds of
thousands of records and be too large to process efficiently....that's why I
wanted to create an XML document that contained only the data the was required
from the particular transformation being done.

I could easily process the XML file to create a SQL string...such as:

select lookupType, code, displayValue, lookupType+code as key
from lookupTable
where key in (orderType15, orderType18, orderType21, transactionType63,
counterparty2398892, ...)

From this queries result set it would be a snap to generate the <refData>
xml.....but here is the clincher. If I were to save that XML in a file so that
it could be brought into the final transformation via document( ) I would first
have to give it a name, save it to a file, pass the name into the XSL, read it
back into memory, use it, and then once the transformation were complete, delete
the file (as I would no longer need it). I could not use a standard name as
every instance would require a different set of reference data, and there may be
many simultaneous instances.

I am wondering how I could take the generated reference XML and pass it into the
XSL in a way that it could be used for lookup purposes without going through the
pains just above. The XSL spec says that document( ) takes either a URI or a
node-set....how do I transform that reference XML into a node-set???

-peter borden



This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan & Co. Incorporated, its
subsidiaries and affiliates.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]