How to concatenate 2 fields

J

jrheltmach

Hi All, have a question I hope someone can help me out with. I have a
file from our financial application here at work that creates
invoices. In it, it pulls data from our SQL Server 2000 database and
using XML, creates text file invoices. Question I have is this. One
of our fields is an ID field called Timekeeper. It's a unique 4 digit
number assigned to every person. What I want to do is create a new
field that will take a -0- and add it to the Timekeeper field.
Example: 01710. How can I concatenate 2 fields in XML where one is a
hardcoded value and one is a database field??

Thanks!
jim
 
J

Joseph Kesselman

How can I concatenate 2 fields in XML where one is a
hardcoded value and one is a database field??

Using what tools? XML is just a data syntax. You're talking about a
programming task, which means you need to pick a programming language
(Java, C, XSLT stylesheets, XQuery or whatever query language you're
already using to retrieve the information and render it as XML ...)
 
J

jrheltmach

Using what tools? XML is just a data syntax. You're talking about a
programming task, which means you need to pick a programming language
(Java, C, XSLT stylesheets, XQuery or whatever query language you're
already using to retrieve the information and render it as XML ...)

I guess I'd be using XSLT stylesheets....Sorry about my ignorance with
this, I just thought I could open the file up in text pad and start
keying away....Anyway, below is where I believe it's pulling the
Timekeeper field from my datasource....

</xsl:choose>
<xsl:text>|</xsl:text>
<xsl:value-of select="tk_id"/> <!-- TIMEKEEPER_ID -->
<xsl:text>|</xsl:text>
 
J

Joseph Kesselman

keying away....Anyway, below is where I believe it's pulling the
Timekeeper field from my datasource....

<xsl:text>|</xsl:text>
<xsl:value-of select="tk_id"/> <!-- TIMEKEEPER_ID -->

OK, so all you hhave to do is modify that to include the additional
data. Since you said you just want to prefix the value with a literal
zero character, the easiest solution is to add it to the literal text
you're already outputting at that point:

<xsl:text>|0</xsl:text>
<xsl:value-of select="tk_id"/>

or, if you wanted to add a trailing zero instead,

<xsl:value-of select="tk_id"/>
<xsl:text>0|</xsl:text>

Obviously more sophisticated things can be done -- combining data from
multiple places in the source document, parameterizing the literal
value, etc. See a good XSLT tutorial for much, much more detail.
(Standard pointers to a lot of good info: http://www.ibm.com/xml for
articles and tutorials, and The XSL FAQ website for many example
solutions from trivial to extremely obscure.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,008
Messages
2,570,270
Members
46,872
Latest member
Stephendes

Latest Threads

Top