[xsl] XSL Stylesheet and using a metadata file

Subject: [xsl] XSL Stylesheet and using a metadata file
From: "Jim Neff" <jneff@xxxxxxxxxxxxxxx>
Date: Tue, 15 Feb 2005 08:16:06 -0500

I am using an XML document as metadata for defining the fields of the flat
files I am trying to generate.

I thought at one point this was working but something must have changed
because I am no longer getting the desired results and I need help getting
back on track.

In my metadata XML file I have the following sample:


This gets loaded into my stylesheet with this command:

<xsl:variable name="field_definitions"

Here is my template:

<xsl:template match="claim_file">

	<xsl:apply-templates select="$field_definitions/type_AA0/*[(plan_id
= current()/provider[1]/claim[1]/plan_id) or (not(plan_id) and
(not(field_no=../type_AA0/*[plan_id =
			<xsl:sort select="field_no" order="ascending"
			<xsl:with-param name="current_context" select="."/>


<xsl:template match="record">
		<xsl:param name="current_context"/>

	<!-- The rest of this code isn't relevant to my problem 
		but eventually (after going through a padding template) the
value gets printed out 
		to the output document -->


Here is a sample of my input XML document :

<?xml version='1.0' encoding='UTF-8'?>
      <provider_organization_name>Best Eye Care</provider_organization_name>

What I want to happen is, I want the field record from the metadata that
corresponds to the plan_id for this file (all claims will have the same
plan_id so I just use the first claim of the first provider to determine
what the plan_id is).  If there is no plan_id in the metadata file that
matches the one for the source file then I want to use the default field
record.  That is, the one with no plan_id elements in it.

What I exepct from the above output is:


What I get is:


My problem is that it is not excluding the 'default' field record from my
metadata file.  If I run this with a different plan_id in the source XML
file, such as "def" then it will produce:  "AA0".

So it ALWAYS includes the default field record and then it will select the
field record for that plan if it matches.  What I want is either or, never
both.  Does that make sense?

Thanks much in advance,
Jim Neff

"Iway owknay atthay Iway owknay othingnay aboutway XSLTAY"

Current Thread