[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Still not getting document() function

Subject: Re: Still not getting document() function
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Thu, 13 Apr 2006 13:38:42 -0500
getting document into xslt file
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.