xsl-list
[Top] [All Lists]

RE: Finding a String and adding a line

2005-05-12 03:57:01
This isn't a valid match pattern:

<xsl:template match='BUSINESS_UNIT type="CHAR"/' >

Perhaps what was intended was

<xsl:template match='BUSINESS_UNIT[(_at_)type="CHAR"]' >

Michael Kay
http://www.saxonica.com/

 

-----Original Message-----
From: rick(_dot_)fraser(_at_)bt(_dot_)com 
[mailto:rick(_dot_)fraser(_at_)bt(_dot_)com] 
Sent: 12 May 2005 11:22
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: [xsl] Finding a String and adding a line

Hi 
 
I am completely new to this and have to solve a problem at 
work - the XSLT is actually in a product called PeopleSoft, 
but I am using Xray to try to solve my problem.
 
I have a piece of code that someone has written (and no 
longer around) - It in itself is not wrong but when the XML 
gets to the destination it expects more and aborts.
 
 
The XML input is something like:
 
<?xml version="1.0"?>
<BT_CONTRACT_PERSON_SYNC>
    <FieldTypes>
        <BT_PROV_SYNC class="R">
            <PERSON_ID type="CHAR"/>
            <BUSINESS_UNIT type="CHAR"/>
            <COUNTRY type="CHAR"/>
        </BT_PROV_SYNC>
        <SPB_PERSON_TBL class="R">
            <PERSON_ID type="CHAR"/>
        </SPB_PERSON_TBL>
    </FieldTypes>
    <MsgData>
        <Transaction>
            <BT_PROV_SYNC class="R">
                <PERSON_ID>600026615</PERSON_ID>
                <BUSINESS_UNIT>00001</BUSINESS_UNIT>
                <COMPANY>503</COMPANY>
                <COUNTRY>GBR</COUNTRY>
            </BT_PROV_SYNC>
            <SPB_PERSON_TBL class="R">
                <PERSON_ID>600026615</PERSON_ID>
            </SPB_PERSON_TBL>
        </Transaction>
    </MsgData>
</BT_CONTRACT_PERSON_SYNC>
 
 
The line <COMPANY>... has been successfully added by the 
XSLT, but the destination expects a corresponding entry in 
the <FieldTypes> list, after <BUSINESS_UNIT type="CHAR"/>.
 
The line <COMPANY type="CHAR"/> has to be added.
 
Here is a cut-down version of the XSLT:
 
 
<?xml version="1.0"?>
<xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:template match="BT_CONTRACT_PERSON_SYNC">
<BT_CONTRACT_PERSON_SYNC>
   <xsl:copy-of select="FieldTypes"/>
   <MsgData>
      <!-- Transaction -->
         <xsl:apply-templates select="MsgData/Transaction"/>
      <!-- /Transaction -->
   </MsgData>
</BT_CONTRACT_PERSON_SYNC>
 
</xsl:template>
<xsl:template match="MsgData/Transaction">
<Transaction>
         <xsl:apply-templates select="BT_PROV_SYNC"/>
         <xsl:copy-of select="SPB_PERSON_TBL"/>
         <xsl:copy-of select="PSCAMA"/>
</Transaction>
</xsl:template>
 
<xsl:template match="BT_PROV_SYNC">
   <xsl:copy>
      <xsl:attribute name="class"> <xsl:value-of 
select="@class"/> </xsl:attribute> 
      <xsl:apply-templates select="node()"/>
   </xsl:copy>
</xsl:template>
 
 
<!-inserted code - -->
<xsl:template match='BUSINESS_UNIT type="CHAR"/' >
     <BUSINESS_UNIT Type="CHAR"/>
     <COMPANY Type="CHAR"/>
</xsl:template>
<!-- inserted code end -->
 
<!-- copy other fields -->
<xsl:template match="*">
   <xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
 
 
When I run this through the application or Xray, it fails 
with a message :
 
Expected token 'EOF' found 'NAME'.
 
BUSINESS_UNIT -->type<--="CHAR"/
 
 
So PLEASE, how is it done?
 
 
 
 

--~------------------------------------------------------------------
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>
--~--





--~------------------------------------------------------------------
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>
--~--