xsl rule
Значит задача такая :
есть исходный xml file
[HTML]<?xml version="1.0" encoding="utf-8"?>
<CSV_FILE>
<ROW>
<Activity>New</Activity>
<Transaction_Type>Trade</Transaction_Type>
<Product_Type>InterestSwaption</Product_Type>
<Originator_ID>TXRA55</Originator_ID>
<Trade_Ref_Nbr>317504Z50_01262007_589</Trade_Ref_Nbr>
<Counterparty_ID>00006191</Counterparty_ID>
<Trade_Date>2007-01-26</Trade_Date>
<Effective_Date_Adjusted>2008-02-05</Effective_Date_Adjusted>
<Termination_Date>2013-02-05</Termination_Date>
<Notional_Currency>USD</Notional_Currency>
<Notional>1500000.0000</Notional>
<Master_Agreement_Date>2001-01-29</Master_Agreement_Date>
<Master_Agreement_Type>ISDA</Master_Agreement_Type>
<Definitions_Type>ISDA2000</Definitions_Type>
<Floating_Rate_Payer>TXRA55</Floating_Rate_Payer>
<Floating_Rate_Option>USD-LIBOR-BBA</Floating_Rate_Option>
<Floating_Rate_Spread>0.0</Floating_Rate_Spread>
<Floating_Leg_Roll_Convention>5</Floating_Leg_Roll_Convention>
<Floating_Leg_Reset_Frequency_Multiplier>3</Floating_Leg_Reset_Frequency_Multiplier>
<Floating_Leg_Reset_Frequency_Period>M</Floating_Leg_Reset_Frequency_Period>
<Floating_Leg_Pay_Relative_To>CalculationPeriodEndDate</Floating_Leg_Pay_Relative_To>
<Floating_Rate_Designated_Maturity>3M</Floating_Rate_Designated_Maturity>
<Floating_Leg_Daycount_Fraction>ACT/360</Floating_Leg_Daycount_Fraction>
<Floating_Leg_Reset_Relative_To>CalculationPeriodStartDate</Floating_Leg_Reset_Relative_To>
<Floating_Leg_Compounding_Method>Flat</Floating_Leg_Compounding_Method>
<Floating_Leg_Calculation_Period_Frequency_Multiplier>3</Floating_Leg_Calculation_Period_Frequency_Multiplier>
<Floating_Leg_Calculation_Period_Frequency_Period>M</Floating_Leg_Calculation_Period_Frequency_Period>
<Fixed_Rate_Payer>00006191</Fixed_Rate_Payer>
<Fixed_Rate>5.1</Fixed_Rate>
<Fixed_Leg_Roll_Convention>5</Fixed_Leg_Roll_Convention>
<Fixed_Leg_Daycount_Fraction>30/360</Fixed_Leg_Daycount_Fraction>
<Fixed_Leg_Pay_Relative_To>CalculationPeriodEndDate</Fixed_Leg_Pay_Relative_To>
<ETC_or_Swaption_Follow_Up_Confirmation>N</ETC_or_Swaption_Follow_Up_Confirmation>
<Swaption_Buyer>00006191</Swaption_Buyer>
<Swaption_Straddle>N</Swaption_Straddle>
<Swaption_Expiration_Date>2013-02-05</Swaption_Expiration_Date>
<Swaption_Premium_Amount>13425.00</Swaption_Premium_Amount>
<Swaption_Premium_Currency>USD</Swaption_Premium_Currency>
<Swaption_Premium_Payment_Date__Adjusted_>2007-01-30</Swaption_Premium_Payment_Date__Adjusted_>
<Swaption_Settlement_Type>CASH</Swaption_Settlement_Type>
<Swaption_Cash_Settlement_Method>CashPrice</Swaption_Cash_Settlement_Method>
<Swaption_Quotation_Rate_Type>Mid</Swaption_Quotation_Rate_Type>
<Termination_Date_BD_Convention>MODFOLLOWING</Termination_Date_BD_Convention>
<Termination_Date_Business_Days>GBLO, USNY</Termination_Date_Business_Days>
<Float_Pymt_BD_Convention>MODFOLLOWING</Float_Pymt_BD_Convention>
<Float_Pymt_Business_Days>GBLO, USNY</Float_Pymt_Business_Days>
<Float_Calc_Period_BD_Convention>MODFOLLOWING</Float_Calc_Period_BD_Convention>
<Float_Calc_Period_Business_Days>GBLO, USNY</Float_Calc_Period_Business_Days>
<Float_Reset_BD_Convention>MODFOLLOWING</Float_Reset_BD_Convention>
<Float_Reset_Business_Days>GBLO, USNY</Float_Reset_Business_Days>
<Float_Initial_Fixing_BD_Convention>NONE</Float_Initial_Fixing_BD_Convention>
<Float_Initial_Fixing_Business_Days>GBLO</Float_Initial_Fixing_Business_Days>
<Float_Initial_Fixing_Lag>-2</Float_Initial_Fixing_Lag>
<Float_Fixing_Dates_BD_Convention>NONE</Float_Fixing_Dates_BD_Convention>
<Float_Fixing_Dates_Business_Days>GBLO</Float_Fixing_Dates_Business_Days>
<Float_Fixing_Dates_Lag>-2</Float_Fixing_Dates_Lag>
<Fixed_Pymt_BD_Convention>MODFOLLOWING</Fixed_Pymt_BD_Convention>
<Fixed_Pymt_Business_Days>GBLO, USNY</Fixed_Pymt_Business_Days>
<Fixed_Calc_Period_BD_Convention>MODFOLLOWING</Fixed_Calc_Period_BD_Convention>
<Fixed_Calc_Period_Business_Days>GBLO, USNY</Fixed_Calc_Period_Business_Days>
<Swptn_Exercise_Business_Days>GBLO, USNY</Swptn_Exercise_Business_Days>
<Swptn_Exercise_BD_Convention>MODFOLLOWING</Swptn_Exercise_BD_Convention>
<Swptn_Exercise_Time_Business_Days>USNY</Swptn_Exercise_Time_Business_Days>
<Swptn_Earliest_Exercise_Time>9:00</Swptn_Earliest_Exercise_Time>
<Swptn_Latest_Exercise_Time>11:00</Swptn_Latest_Exercise_Time>
<Swptn_Valuation_Days>0</Swptn_Valuation_Days>
<Swptn_Valuation_Time_Business_Days>USNY</Swptn_Valuation_Time_Business_Days>
<Swptn_Valuation_BD_Convention>NONE</Swptn_Valuation_BD_Convention>
<Swptn_Valuation_Time>11:00</Swptn_Valuation_Time>
<Swptn_Settlement_BD_Convention>MODFOLLOWING</Swptn_Settlement_BD_Convention>
<Swptn_Settlement_Business_Days>GBLO, USNY</Swptn_Settlement_Business_Days>
<Swptn_Settlement_Pymt_Date__Days_>2</Swptn_Settlement_Pymt_Date__Days_>
<Swptn_Settlement_Currency>USD</Swptn_Settlement_Currency>
<Swptn_Calculation_Agent>AsSpecifiedInMasterAgreement</Swptn_Calculation_Agent>
<Swptn_Exercise_Method>Manual</Swptn_Exercise_Method>
<Swptn_Fallback_Applicable>true</Swptn_Fallback_Applicable>
<Block_Reference_Number>317504Z50_01262007_589</Block_Reference_Number>
<Block_Originator_ID>TXRA55</Block_Originator_ID>
</ROW>
</CSV_FILE>
[/HTML]
он довольно таки длинный так что вставил только одну ноду row
вообще таких row может быть сколько угодно
так же есть xml file с с значениями по умолчанию
[HTML]
<?xml version="1.0" encoding="utf-8"?>
<DefaultValues>
<part1>
<Termination_Date_BD_Convention>
<DefValue RateOption="USD-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="MODFOLLOWING"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="MODFOLLOWING"/>
<DefValue RateOption="NZD-BBR-FRA" Value="MODFOLLOWING"/>
</Termination_Date_BD_Convention>
<Termination_Date_Business_Days>
<DefValue RateOption="USD-LIBOR-BBA" Value="GBLO, USNY"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="GBLO"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="EUTA, GBLO"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="GBLO, JPTO"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="AUSY"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="MXMC"/>
<DefValue RateOption="NZD-BBR-FRA" Value="NZWE"/>
</Termination_Date_Business_Days>
<Fixed_Pymt_BD_Convention>
<DefValue RateOption="USD-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="MODFOLLOWING"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="MODFOLLOWING"/>
<DefValue RateOption="NZD-BBR-FRA" Value="MODFOLLOWING"/>
</Fixed_Pymt_BD_Convention>
<Fixed_Pymt_Business_Days>
<DefValue RateOption="USD-LIBOR-BBA" Value="GBLO, USNY"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="GBLO"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="EUTA, GBLO"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="GBLO, JPTO"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="AUSY"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="MXMC"/>
<DefValue RateOption="NZD-BBR-FRA" Value="NZWE"/>
</Fixed_Pymt_Business_Days>
<Fixed_Calc_Period_BD_Convention>
<DefValue RateOption="USD-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="MODFOLLOWING"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="MODFOLLOWING"/>
<DefValue RateOption="NZD-BBR-FRA" Value="MODFOLLOWING"/>
</Fixed_Calc_Period_BD_Convention>
<Fixed_Calc_Period_Business_Days>
<DefValue RateOption="USD-LIBOR-BBA" Value="GBLO, USNY"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="GBLO"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="EUTA, GBLO"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="GBLO, JPTO"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="AUSY"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="MXMC"/>
<DefValue RateOption="NZD-BBR-FRA" Value="NZWE"/>
</Fixed_Calc_Period_Business_Days>
</part1>
<part2>
<ETC_Type>
<DefValue RateOption="USD-LIBOR-BBA" Value="Optional"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="Optional"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="Optional"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="Optional"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="Optional"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="Optional"/>
<DefValue RateOption="NZD-BBR-FRA" Value="Optional"/>
</ETC_Type>
<ETC_Exercise_Rights>
<DefValue RateOption="USD-LIBOR-BBA" Value="Both"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="Both"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="Both"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="Both"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="Both"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="Both"/>
<DefValue RateOption="NZD-BBR-FRA" Value="Both"/>
</ETC_Exercise_Rights>
<ETC_Exercise_Dates__Days_>
<DefValue RateOption="USD-LIBOR-BBA" Value="-5"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="-5"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="-5"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="-5"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="-5"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="-5"/>
<DefValue RateOption="NZD-BBR-FRA" Value="-5"/>
</ETC_Exercise_Dates__Days_>
<ETC_Exercise_Business_Days>
<DefValue RateOption="USD-LIBOR-BBA" Value="GBLO, USNY"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="GBLO"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="EUTA, GBLO"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="GBLO, JPTO"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="AUSY"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="MXMC"/>
<DefValue RateOption="NZD-BBR-FRA" Value="NZAU, NZWE"/>
</ETC_Exercise_Business_Days>
<ETC_Exercise_BD_Convention>
<DefValue RateOption="USD-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="GBP-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="EUR-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="JPY-LIBOR-BBA" Value="MODFOLLOWING"/>
<DefValue RateOption="AUD-BBR-BBSW" Value="MODFOLLOWING"/>
<DefValue RateOption="MXN-TIIE-Banxico" Value="MODFOLLOWING"/>
<DefValue RateOption="NZD-BBR-FRA" Value="MODFOLLOWING"/>
</ETC_Exercise_BD_Convention>
</part2>
</DefaultValues>
[/HTML]
то вставлял бы в текущую row элемент с именем ноды которой недостает а в нее текст который соответствует value в одной из дочерней ноде DefValue при условии что из текущего row/Floating_Rate_Option/text() = DefValue/@RateOption
я смог только заносить данные в результирующий файл из первого xml и создал переменные на текущий row и ссылку на документ (второй файл)
где хранятся значения по умолчанию.
[HTML]<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="CSV_FILE">
<xsl:element name="{name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="ROW">
<xsl:element name="{name()}">
<xsl:apply-templates/>
<xsl:if test="Product_Type='InterestSwaption' or Product_Type='InterestSwap'">
<xsl:variable name="rate_opt" select="Floating_Rate_Option"/>
<xsl:variable name="default_data" select="document('xml_data.xml')//DefaultValues"/>
<xsl:variable name="current_row" select="./*"/>
<xsl:for-each select="$default_data/part1/*">
<!--Вот отсюда как я не пытался сравнить текущую ноду на соответствие такой же ноды в $current_row/* нечего не выходило -->
<xsl:variable name="sdsddss1" select="."/>
<xsl:variable name="sdsddss" select="$current_row/*[$sdsddss1]"/>
<xsl:if test="boolean('')">
<good/>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>[/HTML]
Вопрос такой, как мне сравнить ноды на схожесть ?
с сылками я решил, кто знает как вставить в текст \t и \n ?
тут вообще люди есть ? :confused: :D
Цитата: Nirex
тут вообще люди есть ? :confused: :D
Нет здесь никого. Только боты. :D
Цитата: Nirex
с последним я тоже уже давно решил. :)
тут вообще люди есть ? :confused: :D
тут вообще люди есть ? :confused: :D
Вот видишь... если немного поработать, то можно самому во всем разобраться ;)
А вообще молодец, что разобрался, а то нередко теятели напостят и ждут, что за них кто-то все сделает...