iterate int xml file using ant

后端 未结 3 1477
无人共我
无人共我 2021-01-07 10:39

I´ve a Xml file with the struct below. I want to read the nod by node and call a specific task with the values without commom separator.In Ant this is possible ?

<         


        
3条回答
  •  旧巷少年郎
    2021-01-07 11:41

    Use the XSLT task to process the input XML file into an ANT script that is subsequently executed.

    Example

    |-- build.xml
    |-- projects-process.xsl
    `-- projects.xml
    

    Running will process the information in the

    $ ant
    Buildfile: /home/mark/tmp/build.xml
    
    run-projects:
         [xslt] Processing /home/mark/tmp/projects.xml to /home/mark/tmp/build-tmp.xml
         [xslt] Loading stylesheet /home/mark/tmp/projects-process.xsl
    
    build:
    
    dosomething:
         [echo] DOSOMETHING: 'Project 1' 'http://someurl1' 'project1'"
    
    dosomething:
         [echo] DOSOMETHING: 'Project 2' 'http://someurl2' 'project2'"
    
    BUILD SUCCESSFUL
    

    projects.xml

    
    
        
            Project 1
            http://someurl1
            project1
        
    
        
            Project 2
            http://someurl2
            project2
        
    
    
    

    projects-process.xsl

    This XSLT stylesheet is used to generate an ANT script

    
    
        
    
        
            
    
                
                    
                
    
                
                    DOSOMETHING: '${name}' '${url}' '${package}'"
                
    
            
        
    
        
            
                
                
                
            
        
    
    
    

    build.xml

    Runs the XSLT transform to process the projects.xml file and generate an ANT build file

    
    
        
            
    
            
        
    
        
            
        
    
    
    

提交回复
热议问题