如何在xml文件上添加条件,配置是否加载

时间:2014-03-08 08:04:01

标签: java xml

我有一个XML文件,其中包含一些提供数据库连接的配置。我从java类获取数据库连接属性,现在我想要的是我需要XML文件中的条件,如果条件为真则则包含数据库标记的标记将是可访问的,否则将不会。我想在我的XML中放置自定义条件。我发布了我的XML文件..

<?xml version="1.0" encoding="UTF-8"?>

<Adapter name="Hua_GPRS_CS5_4.7" type="ASN.1" version="1.0" description="Huawie GPRS Output CDR Version 4.7"
         execclass="hua.gprs.HuaGPRSFileExecutor" parallel="1" mode="server" statusfile="HuaGPRSStatus.csv"
         merge_factor="1" active="true">

i want to put conditions here 
    <DBConfig id="1" name="jjj" drivername="oracle.jdbc.driver.OracleDriver" hostname="localhost" portname="1521"
              dbname="rrr" servicename="orcl" user="param" password="param" sid="orcl">
        <TableConfig ID="1" TableName="">
        </TableConfig>
    </DBConfig>


    <DirConfig>
        <poll protocol="" host="" path="./data/huagprs/source" pwd="" user="" clogging="true" startdir="" enddir=""
              pattern="(.*)\.(\d{6})(\d{6})(\d{4})_(.*)" metafields="fileName,exchange,fileDate,fileTime,fileSeq,junk"/>
        <source path="./data/huagprs/source" clogging="false"/>
        <backup path="./data/huagprs/backup" active="false"/>
        <staging path="./data/huagprs/staging" clogging="false"/>
        <output path="./data/huagprs/output" clogging="false" compress="gz"/>
        <error path="./data/huagprs/error" clogging="true"/>
        <target protocol="" host="" path="/" pwd="" user="" active="true"/>
    </DirConfig>

    <DataDefinition parser="com.etl.parser.core.CommaSepParser" type="#Grammar type#"
                    description="#Grammar Description#" ignoreinitLines="" fileheaderlines="1" datastartline="2"
                    recordseparator="\n" fieldseparator="," ignoreemptyrecord="FALSE">
        <Record parser="com.etl.parser.core.CommaSepParser" name="Statistics CDR" displayPos="null" givenName="null"
                separatorChar=","
                quoteChar="\\'" escapeChar="\n" ignoreLeadingWhiteSpace="FALSE" strictQuotes="FALSE"
                ignoreQuotes="FALSE" bracesHandle="FALSE">
        </Record>
    </DataDefinition>

</Adapter> 

DBConfig是我的xml标签,其中包含我需要此标签上的条件的凭据。我会说这将是我的自定义标签,我将放置我的条件。

0 个答案:

没有答案