Greetings,
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:
<records>
<type_AA0>
<record>
<field_no>1</field_no>
<starting_position>1</starting_position>
<length>3</length>
<justification>L</justification>
<content></content>
<default_value>AA0</default_value>
<data_type>text</data_type>
<name>record_id</name>
</record>
<record>
<field_no>1</field_no>
<starting_position>1</starting_position>
<length>3</length>
<justification>L</justification>
<content></content>
<default_value>xxx</default_value>
<data_type>text</data_type>
<name>record_id</name>
<plan_id>abc</plan_id>
</record>
</type_AA0>
</records>
This gets loaded into my stylesheet with this command:
<xsl:variable name="field_definitions"
select="document('my_metadata.xml')/records"/>
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 =
current()/provider[1]/claim[1]/plan_id]/field_no)))]">
<xsl:sort select="field_no" order="ascending"
data-type="number"/>
<xsl:with-param name="current_context" select="."/>
</xsl:apply-templates>
</xsl:template>
<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 -->
</xsl:template>
Here is a sample of my input XML document :
<?xml version='1.0' encoding='UTF-8'?>
<claim_file>
<process_date>2005-02-10T02:21:49</process_date>
<provider>
<provider_organization_name>Best Eye Care</provider_organization_name>
<claim>
<plan_id>abc</plan_id>
</claim>
</provider>
</claim_file>
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:
"abc"
What I get is:
"AA0abc"
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"
--~------------------------------------------------------------------
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>
--~--