xsl-list
[Top] [All Lists]

Re: [xsl] Still not getting document() function

2006-04-13 11:39:09
Addressing your email slightly out of order:

So, basic question #1: I want to print the (up to) six lines on the first
page, so I can put them in a window envelope.  Any one of the lines might
not be there.  Given this input file, I'd like the following output (which
will be in a table):

Do you really just want to print "six lines" or do you want to print
the text value of those attributes?  What do you mean it'll be in a
table?  Text ouput, xsl-fo output, more xml output, html output, or
something competely different?

I'm going to just show you how you might approach the problem:

<!-- I'm assuming I'm in some other template.  You're processing the
main xml file, but now need to refer to the address file.... -->
start of template
....

<xsl:apply-templates select="document('addresses.xml')/lab:ClInfo" />

....end of template

<!-- then just add some templates to the xslt.  Since everything is in
another namespace, we don't have to worry about mode switching or
anything like that -->

<xsl:template match="lab:docname" priority="1.5">
  <xsl:text>Yay! </xsl:text><xsl:value-of select="normalize-space(.)"
/><xsl:text> works for us.&#10;</xsl:text>
</xsl:template>

<xsl:template match="lab:mailing/lab:*">
 <xsl:value-of select="normalize-space(.)" /><xsl:text>&#10;</xsl:text>
</xsl:template>

Modify these as appropriate.  You'll probably want to make addReport
change the text and not docname.

Dr Zachary Smith
Athena Diagnostics
Four Biotech Park
377 Plantation St.
Worcester, MA  01605

Additional report to: Will Robinson

How do I get this?

Pretty much the exact same as you'd normally get it in XSLT.


I know you can read in a document using the document() function.  I need to
know how to access the elements in the document.

I will be generating a file with one or two addresses for mailing.  For each
address in the document, I would like to loop to transform into a new
document for printing.  I have two ways of doing this:

It's not clear why you need to call document from your problem
statement.  If you've given a fair description of your problem there
should be no need to call document.  I'm going to assume that there is
a condition that you're going to use the XML file that the xslt is
processing in order to choose addresses.  If you're trying to get to
something else you need to describe your problem at a broader level.


1) Create the XML file with all addresses, then modify the XSLT file to do a
for-each;
2) Create the XML file with one address, transform, create another XML file,
transform.

This seems like a red herring.  What does this have to do with the
document() questions?

The lab tag is to differentiate it from the other tag in the other XML file
and the XSLT file.

It's not a "tag" it's a namespace.  I occasionally stumble on
terminology (I think today I mentioned current node in one of my
emails when I should said context node) but tag has a very specific
meaning as the text between <> when dealing with transformations.


Basic question #2: is there any improvement I can make to the output file so
that it's easier to select the data?  The only thing I want to keep are the
names of the data nodes (docname, addrName, addrStreet, addrZIP, addrZIP2,
addReportTo) because these are object names.

How the heck are we supposed to know the answer to this when we don't
know why you're selecting certain elements?

Jon Gorman

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--