The Extensible Markup Language XML

The XML specification defines a language for text based data files. It includes XSD schema definitions for validation and XSLT for stylesheet transformation. Many additional tools are available to parse and query data.

Programming XML

XQilla

The Java package and dependency management tool Maven uses a XML based Project Object Model definition. The dependencies are defined in pom.xml files. The pom.xml files can be prepared beforehand. Stylesheet definitions or Xquery can be used to preprocess XML files.

xqilla
#!/bin/bash
java -version
mvn --version
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -Dmaven.repo.local=/tmp/pub/repo

xqilla -i my-app/pom.xml <( cat <<-'POM'
        declare namespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
        declare default element namespace "http://maven.apache.org/POM/4.0.0";
        declare variable $build external ;
                element {"project"} {
                        attribute {"xsi:schemaLocation"} {
                                "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
                        },
                        ./project/*,
                        doc($build)
                }
POM
) -v build <( cat <<-'XML'
        <?xml version="1.0"?>
        <build xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <plugins>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-site-plugin</artifactId>
                  <version>3.3</version>
                </plugin>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                  <version>2.7</version>
                </plugin>
                <!-- any other plugins -->
                <plugin>
                  <artifactId>maven-clean-plugin</artifactId>
                  <version>3.1.0</version>
                  <executions>
                        <execution>
                          <id>default-clean</id>
                          <phase>clean</phase>
                          <goals>
                                <goal>clean</goal>
                          </goals>
                        </execution>
                  </executions>
                </plugin>
                <plugin>
                  <artifactId>maven-assembly-plugin</artifactId>
                  <version>3.1.0</version>
                  <configuration>
                        <descriptorRefs>
                          <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                          <manifest>
                                <mainClass>com.mycompany.app.App</mainClass>
                          </manifest>
                        </archive>
                  </configuration>
                  <executions>
                        <execution>
                          <id>make-assembly</id>
                          <!-- this is used for inheritance merges -->
                          <phase>package</phase>
                          <!-- bind to the packaging phase -->
                          <goals>
                                <goal>single</goal>
                          </goals>
                        </execution>
                  </executions>
                </plugin>
          </plugins>
        </build>
XML
) | xmllint --format --nowarning --output my-app/pom.xml -

cat my-app/pom.xml

mvn -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6 -Dmaven.repo.local=/tmp/pub/repo --file my-app/pom.xml help:effective-pom

mvn dependency:tree -Dverbose --file=my-app/pom.xml

mvn -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6 -Dmaven.repo.local=/tmp/pub/repo --file my-app/pom.xml dependency:tree

mvn compile -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6 -Dmaven.repo.local=/tmp/pub/repo --file my-app/pom.xml

mvn test -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6 -Dmaven.repo.local=/tmp/pub/repo --file my-app/pom.xml

mvn package -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6 -Dmaven.repo.local=/tmp/pub/repo --file my-app/pom.xml

jar cvfe my-app.jar com.mycompany.app.App  -C my-app/target/classes .

mvn -Dmaven.compiler.source=1.6 -Dmaven.coiler.target=1.6 -Dmaven.repo.local=/tmp/pub/repo --file my-app/pom.xml -Ddependency.locations.enabled=false site

modules
#!/bin/sh
0<<-XQUERY \
4<<-MODULE \
xqilla /proc/self/fd/0
        xquery version "1.0";
        import module namespace hello="hello" at "/proc/self/fd/4";
    declare variable $x as xs:string := "7";

        hello:world()
XQUERY
        xquery version "1.0";
        module namespace hello = "hello";

        declare function hello:world()
        {
          "hello world"
        };
MODULE

Xmllint

xmllint
xmllint --shell XML-FILE <<<$'setrootns\ncd /office:document/body/\ncat'