How can i get just some info from XML using XSLT? -
i want fields xml, here xml:
<server xmlns="urn:jboss:domain:1.4"> <extensions> ... </extensions> <management> ... </management> <profile> <subsystem xmlns="urn:jboss:domain:logging:1.2"> ... </subsystem> <subsystem xmlns="urn:jboss:domain:cmp:1.0"/> <subsystem xmlns="urn:jboss:domain:datasources:1.1"> <datasources> <datasource jta="true" jndi-name="java:/calypso/datasources/calypsods" pool-name="calypsods" enabled="true" use-ccm="false"> <connection-url>jdbc:oracle:thin:@//tcomora-app.t-maps.local:1521/tit1cal.ora.bde.es</connection-url> <driver>oracle</driver> <pool> <min-pool-size>5</min-pool-size> <max-pool-size>200</max-pool-size> </pool> <security> <user-name>tit1cadm</user-name> <password>tit1cadm</password> </security> <validation> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.oraclevalidconnectionchecker" /> <validate-on-match>true</validate-on-match> <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.oracleexceptionsorter" /> </validation> <timeout> <set-tx-query-timeout>true</set-tx-query-timeout> <blocking-timeout-millis>5000</blocking-timeout-millis> <idle-timeout-minutes>15</idle-timeout-minutes> </timeout> <statement> <track-statements>false</track-statements> </statement> </datasource> <drivers> <driver name="oracle" module="com.oracle.ojdbc"> <xa-datasource-class>oracle.jdbc.oracledriver</xa-datasource-class> </driver> </drivers> </datasources> </subsystem> <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1"> <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="60000" auto-deploy-zipped="true" auto-deploy-exploded="true" deployment-timeout="3600"/> </subsystem> <subsystem xmlns="urn:jboss:domain:ee:1.1"> <spec-descriptor-property-replacement>true</spec-descriptor-property-replacement> <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement> </subsystem> <subsystem xmlns="urn:jboss:domain:ejb3:1.4"> <session-bean> <stateless> <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/> </stateless> <stateful default-access-timeout="5000" cache-ref="simple"/> <singleton default-access-timeout="5000"/> </session-bean> <mdb> <resource-adapter-ref resource-adapter-name="mdb-hornetq-ra"/> <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> </mdb> <pools> <bean-instance-pools> <strict-max-pool name="slsb-strict-max-pool" max-pool-size="200" instance-acquisition-timeout="10" instance-acquisition-timeout-unit="seconds"/> <strict-max-pool name="mdb-strict-max-pool" max-pool-size="50" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="minutes"/> </bean-instance-pools> </pools> <caches> <cache name="simple" aliases="nopassivationcache"/> <cache name="passivating" passivation-store-ref="file" aliases="simplestatefulcache"/> </caches> <passivation-stores> <file-passivation-store name="file"/> </passivation-stores> <async thread-pool-name="default"/> <timer-service thread-pool-name="default"> <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/> </timer-service> <remote connector-ref="remoting-connector" thread-pool-name="remoting"> <channel-creation-options> <option name="worker_read_threads" value="8" type="xnio"/> <option name="worker_write_threads" value="8" type="xnio"/> <option name="max_inbound_messages" value="200" type="remoting"/> <option name="max_outbound_messages" value="200" type="remoting"/> </channel-creation-options> </remote> <thread-pools> <thread-pool name="default"> <max-threads count="10"/> <keepalive-time time="100" unit="milliseconds"/> </thread-pool> <thread-pool name="remoting"> <max-threads count="200"/> <keepalive-time time="1000" unit="milliseconds"/> </thread-pool> </thread-pools> <iiop enable-by-default="false" use-qualified-name="false"/> <default-security-domain value="other"/> <default-missing-method-permissions-deny-access value="false"/> </subsystem> <subsystem xmlns="urn:jboss:domain:infinispan:1.4"> <cache-container name="web" aliases="standard-session-cache" default-cache="local-web" module="org.jboss.as.clustering.web.infinispan"> <local-cache name="local-web" batching="true"> <file-store passivation="false" purge="false"/> </local-cache> </cache-container> <cache-container name="hibernate" default-cache="local-query" module="org.jboss.as.jpa.hibernate:4"> <local-cache name="entity"> <transaction mode="non_xa"/> <eviction strategy="lru" max-entries="10000"/> <expiration max-idle="100000"/> </local-cache> <local-cache name="local-query"> <transaction mode="none"/> <eviction strategy="lru" max-entries="10000"/> <expiration max-idle="100000"/> </local-cache> <local-cache name="timestamps"> <transaction mode="none"/> <eviction strategy="none"/> </local-cache> </cache-container> </subsystem> <subsystem xmlns="urn:jboss:domain:jacorb:1.3"> <orb socket-binding="jacorb" ssl-socket-binding="jacorb-ssl"> <initializers transactions="spec" security="identity"/> </orb> </subsystem> <subsystem xmlns="urn:jboss:domain:jaxr:1.1"> <connection-factory jndi-name="java:jboss/jaxr/connectionfactory"/> </subsystem> <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> <subsystem xmlns="urn:jboss:domain:jca:1.1"> <archive-validation enabled="true" fail-on-error="true" fail-on-warn="false"/> <bean-validation enabled="true"/> <default-workmanager> <short-running-threads> <core-threads count="50"/> <queue-length count="50"/> <max-threads count="50"/> <keepalive-time time="10" unit="seconds"/> </short-running-threads> <long-running-threads> <core-threads count="50"/> <queue-length count="50"/> <max-threads count="50"/> <keepalive-time time="10" unit="seconds"/> </long-running-threads> </default-workmanager> </subsystem> <subsystem xmlns="urn:jboss:domain:jdr:1.0"/> <subsystem xmlns="urn:jboss:domain:jmx:1.2"> <expose-resolved-model/> <expose-expression-model/> <remoting-connector/> </subsystem> <subsystem xmlns="urn:jboss:domain:jpa:1.1"> <jpa default-datasource="" default-extended-persistence-inheritance="deep"/> </subsystem> <subsystem xmlns="urn:jboss:domain:jsf:1.0"/> <subsystem xmlns="urn:jboss:domain:jsr77:1.0"/> <subsystem xmlns="urn:jboss:domain:mail:1.0"> <mail-session jndi-name="java:jboss/mail/default"> <smtp-server outbound-socket-binding-ref="mail-smtp"/> </mail-session> </subsystem> <subsystem xmlns="urn:jboss:domain:messaging:1.3"> <hornetq-server> <persistence-enabled>true</persistence-enabled> <security-enabled>false</security-enabled> <jmx-management-enabled>true</jmx-management-enabled> <journal-type>asyncio</journal-type> <journal-sync-non-transactional>false</journal-sync-non-transactional> <journal-file-size>10240000</journal-file-size> <journal-min-files>2</journal-min-files> <connectors> <netty-connector name="netty" socket-binding="messaging"> <param key="use-nio" value="true"/> </netty-connector> <netty-connector name="netty-throughput" socket-binding="messaging-throughput"> <param key="batch-delay" value="50"/> </netty-connector> <in-vm-connector name="in-vm" server-id="0"/> <connector name="calypso-jms-connector"> <factory-class>org.hornetq.core.remoting.impl.netty.nettyconnectorfactory</factory-class> <param key="host" value="es0tlv06-app.t-maps.local"/> <param key="port" value="5445"/> </connector> </connectors> <acceptors> <netty-acceptor name="netty" socket-binding="messaging"> <param key="direct-deliver" value="false"/> <param key="use-nio" value="true"/> </netty-acceptor> <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput"> <param key="batch-delay" value="50"/> <param key="direct-deliver" value="false"/> </netty-acceptor> <in-vm-acceptor name="in-vm" server-id="0"/> </acceptors> <security-settings> <security-setting match="#"> <permission type="send" roles="basic_user_role"/> <permission type="consume" roles="basic_user_role"/> <permission type="createnondurablequeue" roles="basic_user_role"/> <permission type="deletenondurablequeue" roles="basic_user_role"/> </security-setting> </security-settings> <address-settings> <!-- calypso topic --> <address-setting match="jms.topic.calypso"> <dead-letter-address>jms.queue.dlq</dead-letter-address> <expiry-address>jms.queue.expiryqueue</expiry-address> <redelivery-delay>0</redelivery-delay> <max-size-bytes>250857600</max-size-bytes> <page-size-bytes>25085760</page-size-bytes> <address-full-policy>page</address-full-policy> <message-counter-history-day-limit>10</message-counter-history-day-limit> </address-setting> <!--default catch all--> <address-setting match="#"> <dead-letter-address>jms.queue.dlq</dead-letter-address> <expiry-address>jms.queue.expiryqueue</expiry-address> <redelivery-delay>0</redelivery-delay> <max-size-bytes>10485760</max-size-bytes> <page-size-bytes>5048576</page-size-bytes> <address-full-policy>page</address-full-policy> <message-counter-history-day-limit>10</message-counter-history-day-limit> </address-setting> </address-settings> <jms-connection-factories> <connection-factory name="hornetq-ra"> <connectors> <connector-ref connector-name="in-vm"/> </connectors> <entries> <entry name="java:/calypso/jms/connectionfactory"/> </entries> </connection-factory> <connection-factory name="remoteconnectionfactory"> <connectors> <connector-ref connector-name="netty"/> </connectors> <entries> <entry name="java:jboss/exported/jms/connectionfactory"/> </entries> </connection-factory> <pooled-connection-factory name="mdb-hornetq-ra"> <transaction mode="none"/> <connectors> <connector-ref connector-name="in-vm"/> </connectors> <entries> <entry name="java:/calypso/jms/pooledconnectionfactory"/> </entries> </pooled-connection-factory> </jms-connection-factories> <jms-destinations> <jms-topic name="calypso.adminevents"> <entry name="topic/calypsoadmin"/> <entry name="java:jboss/exported/topic/calypsoadmin"/> </jms-topic> <jms-topic name="calypso"> <entry name="topic/calypso"/> <entry name="java:jboss/exported/topic/calypso"/> </jms-topic> <jms-queue name="calypsotobony"> <entry name="queue/calypsotobony"/> <durable>false</durable> </jms-queue> <jms-queue name="bonytocalypso"> <entry name="queue/bonytocalypso"/> <durable>false</durable> </jms-queue> <jms-queue name="calypsotogscc"> <entry name="queue/calypsotogscc"/> <durable>false</durable> </jms-queue> <jms-queue name="gscctocalypso"> <entry name="queue/gscctocalypso"/> <durable>false</durable> </jms-queue> <jms-queue name="calypsotoswift"> <entry name="queue/calypsotoswift"/> <durable>false</durable> </jms-queue> <jms-queue name="swifttocalypso"> <entry name="queue/swifttocalypso"/> <durable>false</durable> </jms-queue> <jms-queue name="dlq"> <entry name="queue/dlq"/> <durable>false</durable> </jms-queue> <jms-queue name="expiryqueue"> <entry name="queue/expiryqueue"/> <durable>false</durable> </jms-queue> </jms-destinations> </hornetq-server> </subsystem> <subsystem xmlns="urn:jboss:domain:naming:1.2"> <remote-naming/> </subsystem> <subsystem xmlns="urn:jboss:domain:pojo:1.0"/> <subsystem xmlns="urn:jboss:domain:remoting:1.1"> <connector name="remoting-connector" socket-binding="remoting" security-realm="calypsosecurityrealm"/> </subsystem> <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0"/> <subsystem xmlns="urn:jboss:domain:sar:1.0"/> <subsystem xmlns="urn:jboss:domain:security:1.2"> <security-domains> <security-domain name="calypso-db-security-domain" cache-type="default"> <authentication> <login-module code="com.calypso.authentication.module.calypsoauditloginmodule" flag="required" module="deployment.dataserver.war"/> <login-module code="database" flag="required"> <module-option name="dsjndiname" value="java:/calypso/datasources/calypsods"/> <module-option name="principalsquery" value="select hex_password user_name user_name=? , acc_locked_date null"/> <module-option name="rolesquery" value="select 'admserver','roles' group_access userrole, group_access usergroup, user_name u u.user_name=? , u.user_name=usergroup.access_value , userrole.group_name = usergroup.group_name , ( ( userrole.access_id=1 , userrole.access_value='admserver' ) or ( usergroup.access_id=0 , usergroup.group_name in ( select ugn.group_name user_group_name ugn ugn.is_admin_b=1 or ugn.group_name='admin' ) ) ) union select 'basic_user_role', 'roles' calypso_info"/> <module-option name="hashalgorithm" value="sha-1"/> <module-option name="hashcharset" value="utf-8"/> <module-option name="hashencoding" value="hex"/> </login-module> </authentication> </security-domain> <security-domain name="other" cache-type="default"> <authentication> <login-module code="remoting" flag="optional"> <module-option name="password-stacking" value="usefirstpass"/> </login-module> <login-module code="realmdirect" flag="required"> <module-option name="password-stacking" value="usefirstpass"/> </login-module> </authentication> </security-domain> <security-domain name="jboss-web-policy" cache-type="default"> <authorization> <policy-module code="delegating" flag="required"/> </authorization> </security-domain> <security-domain name="jboss-ejb-policy" cache-type="default"> <authorization> <policy-module code="delegating" flag="required"/> </authorization> </security-domain> </security-domains> </subsystem> <subsystem xmlns="urn:jboss:domain:threads:1.1"/> <subsystem xmlns="urn:jboss:domain:transactions:1.2"> <core-environment> <process-id> <uuid/> </process-id> </core-environment> <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> <coordinator-environment default-timeout="1800"/> </subsystem> <subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false"> <connector name="http" protocol="http/1.1" scheme="http" socket-binding="http"/> <connector name="https" protocol="http/1.1" scheme="https" socket-binding="https" secure="true"> <ssl name="https" key-alias="calypso" password="maps01" certificate-key-file="/home/apst/mop/key/server.keystore" certificate-file="/home/apst/mop/key/client.truststore"/> </connector> <connector name="management-https" protocol="http/1.1" scheme="https" secure="true" socket-binding="management-https"> <ssl name="https" key-alias="calypso" password="maps01" certificate-key-file="/home/apst/mop/key/server.keystore" certificate-file="/home/apst/mop/key/client.truststore"/> </connector> <virtual-server name="default-host" enable-welcome-root="true"> <alias name="localhost"/> </virtual-server> </subsystem> <subsystem xmlns="urn:jboss:domain:webservices:1.2"> <modify-wsdl-address>true</modify-wsdl-address> <wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host> <endpoint-config name="standard-endpoint-config"/> <endpoint-config name="recording-endpoint-config"> <pre-handler-chain name="recording-handlers" protocol-bindings="##soap11_http ##soap11_http_mtom ##soap12_http ##soap12_http_mtom"> <handler name="recordinghandler" class="org.jboss.ws.common.invocation.recordingserverhandler"/> </pre-handler-chain> </endpoint-config> <client-config name="standard-client-config"/> </subsystem> <subsystem xmlns="urn:jboss:domain:weld:1.0"/> </profile>
and im trying execute xsl:
<?xml version="1.0" encoding='utf-8'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="profile"> <profile> <xsl:apply-templates select="subsystem"/> </profile> </xsl:template> <xsl:template match="subsystem" > <subsystem> <xsl:value-of select="./@xmlns"/> <xsl:apply-templates select="datasources"/> </subsystem> </xsl:template> <xsl:template match="datasources" > <datasources> <xsl:apply-templates select="datasource"/> </datasources> </xsl:template> <xsl:template match="datasource"> <datasource> <xsl:value-of select="./@jta"/> <xsl:value-of select="./@jndi-name"/> <xsl:value-of select="./@pool-name"/> <xsl:value-of select="./@enabled"/> <xsl:value-of select="./@use-ccm"/> <xsl:apply-templates select="connection-url"/> <xsl:apply-templates select="driver"/> <xsl:apply-templates select="pool"/> <xsl:apply-templates select="security"/> <xsl:apply-templates select="validation"/> <xsl:apply-templates select="statement"/> </datasource> </xsl:template> <xsl:template match="connection-url"> <connection-url> <xsl:value-of select="." /> </connection-url> </xsl:template> <xsl:template match="driver" > <driver> <xsl:apply-templates select="hostname"/> </driver> </xsl:template> <xsl:template match="pool"> <pool> <xsl:apply-templates select="min-pool-size"/> <xsl:apply-templates select="max-pool-size"/> </pool> </xsl:template> <xsl:template match="security"> <security> <xsl:apply-templates select="user-name"/> <xsl:apply-templates select="password"/> </security> </xsl:template> <xsl:template match="validation"> <validation> <xsl:apply-templates select="valid-connection-checker"/> <xsl:apply-templates select="validate-on-match"/> <xsl:apply-templates select="exception-sorter"/> </validation> </xsl:template> <xsl:template match="statement"> <statement> <xsl:apply-templates select="track-statements"/> </statement> </xsl:template> <xsl:template match="hostname"> <hostname> <xsl:value-of select="."/> </hostname> </xsl:template> <xsl:template match="min-pool-size"> <min-pool-size> <xsl:value-of select="."/> </min-pool-size> </xsl:template> <xsl:template match="max-pool-size"> <max-pool-size> <xsl:value-of select="."/> </max-pool-size> </xsl:template> <xsl:template match="user-name"> <user-name> <xsl:value-of select="."/> </user-name> </xsl:template> <xsl:template match="password"> <password> <xsl:value-of select="."/> </password> </xsl:template> <xsl:template match="valid-connection-checker"> <valid-connection-checker> <xsl:value-of select="."/> </valid-connection-checker> </xsl:template> <xsl:template match="validate-on-match"> <validate-on-match> <xsl:value-of select="."/> </validate-on-match> </xsl:template> <xsl:template match="exception-sorter"> <exception-sorter> <xsl:value-of select="."/> </exception-sorter> </xsl:template> <xsl:template match="track-statements"> <track-statements> <xsl:value-of select="."/> </track-statements> </xsl:template> </xsl:stylesheet>
but doesnt working. want info inside "server/profile/subsystem/datasources"
hope have solution. ^^
you have consider namespaces used in xml, , register them in xslt so:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:domain="urn:jboss:domain:1.4" xmlns:datasources="urn:jboss:domain:datasources:1.1"> <xsl:template match="/"> <xsl:copy-of select="/domain:server/domain:profile/datasources:subsystem/datasources:datasources"/> </xsl:template>
Comments
Post a Comment