/jboss-as-7.1.1.Final/testsuite/integration/src/test/xslt/changeDatabase.xsl
Extensible Stylesheet Language Transformations | 94 lines | 82 code | 12 blank | 0 comment | 0 complexity | b31aba32615438785ec4924b252f8e87 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
1<?xml version="1.0" encoding="UTF-8"?>
2<!-- See http://www.w3.org/TR/xslt -->
3
4 <!--
5 An XSLT style sheet which will change the existing datasource definition to the desired database.
6 This is done by changing:
7 <server>
8 ...
9 <profile>
10 ...
11 <subsystem xmlns="urn:jboss:domain:datasources:1.0">
12 <datasource jndi-name="java:jboss/datasources/ExampleDS enabled="true" use-java-context="true" pool-name="H2DS"/>
13 <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
14 <driver>h2</driver>
15 <pool></pool>
16 <security>
17 <user-name>sa</user-name>
18 <passsword>sa</password>
19 </datasource>
20 <drivers>
21 <driver name="h2" module="com.h2database.h2">
22 <xa-datasource-class>org.h2.jdcx.JdbcDataSource</xa-datasource-class>
23 </driver>
24 </drivers>
25 </subsystem>
26 ...
27 </profile>
28 ...
29 </server>
30
31 to the following, in which the existing datasource definition is completely removed and replaced by the
32 new datasource definition (where the driver is deployed into standalone/deployments and not loaded as a
33 module):
34
35 <server>
36 ...
37 <profile>
38 ...
39 <subsystem xmlns="urn:jboss:domain:datasources:1.0">
40 <datasource jndi-name="java:jboss/datasources/ExampleDS enabled="true" use-java-context="true" pool-name="H2DS"/>
41 <connection-url>${ds.jdbc.url}</connection-url>
42 <driver>${ds.jdbc.driver}</driver>
43 <pool></pool>
44 <security>
45 <user-name>${ds.jdbc.user}</user-name>
46 <passsword>${ds.jdbc.pass}</password>
47 </datasource>
48 </subsystem>
49 ...
50 </profile>
51 ...
52 </server>
53
54 -->
55
56<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
57 xmlns:ds="urn:jboss:domain:datasources:1.0">
58 <xsl:output method="xml" indent="yes"/>
59
60 <xsl:param name="ds.jdbc.driver.jar" select="'fred'"/>
61 <xsl:param name="ds.jdbc.url" select="'wilma'"/>
62 <xsl:param name="ds.jdbc.user" select="'test'"/>
63 <xsl:param name="ds.jdbc.pass" select="'test'"/>
64
65 <xsl:variable name="newDatasourceDefinition">
66 <ds:datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExamplePool" enabled="true" jta="true"
67 use-java-context="true">
68 <ds:connection-url><xsl:value-of select="$ds.jdbc.url"/></ds:connection-url>
69 <ds:driver><xsl:value-of select="$ds.jdbc.driver.jar"/></ds:driver>
70 <ds:security>
71 <ds:user-name><xsl:value-of select="$ds.jdbc.user"/></ds:user-name>
72 <ds:password><xsl:value-of select="$ds.jdbc.pass"/></ds:password>
73 </ds:security>
74 </ds:datasource>
75 </xsl:variable>
76
77 <!-- Replace the old datasource with the new. -->
78 <xsl:template match="//ds:subsystem/ds:datasources/ds:datasource[@jndi-name='java:jboss/datasources/ExampleDS']">
79 <!-- http://docs.jboss.org/ironjacamar/userguide/1.0/en-US/html/deployment.html#deployingds_descriptor -->
80 <xsl:copy-of select="$newDatasourceDefinition"/>
81 </xsl:template>
82
83 <!-- Get rid of the default driver defs. -->
84 <xsl:template match="//ds:subsystem/ds:datasources/ds:drivers"/>
85
86 <!-- Copy everything else. -->
87 <xsl:template match="@*|node()">
88 <xsl:copy>
89 <xsl:apply-templates select="@*|node()"/>
90 </xsl:copy>
91 </xsl:template>
92
93</xsl:stylesheet>
94