[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Copying XML tags into XSL variable - Urgent

Subject: RE: Copying XML tags into XSL variable - Urgent
From: "Macaulay,Malcolm (US)" <Malcolm.Macaulay2@xxxxxxxxx>
Date: Wed, 25 Sep 2002 14:29:27 -0500
xsl modify variable
Hi Vignesh,

I'm not quite sure why you are using a variable but here is an XLST which outputs what you want:

XSLT::

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	
	<xsl:template match="/">
		<output>
			<xsl:apply-templates select="nds/input/modify/modify-attr[@attr-name='ROLE' and add-value]"/>
		</output>
	</xsl:template>
	
	<xsl:template match="modify-attr[@attr-name='ROLE']">
	
		<!-- assign tree into variable (no particular reason - just to demonstrate) -->
		<xsl:variable name="tempTree" select="."/>
	
		<!-- copy temp tree to output. This could be done directly without first assigning to variable -->
		<xsl:copy-of select="$tempTree"/>
	
	</xsl:template>
</xsl:stylesheet>

Results XML:

<?xml version="1.0" encoding="UTF-8"?>
<output>
	<modify-attr attr-name="ROLE" xmlns:jdbc="urn:dirxml:jdbc">
		<add-value>
			<value type="string">ole</value>
		</add-value>
		<add-value>
			<value type="string">staffportal</value>
		</add-value>
	</modify-attr>
</output>

If you just want the tree in the output then you don't need to use a variable - you can just put it into the output directly with <xsl:copy-of .../>

The XPath in your template:

<xsl::apply-templates
select="modify-attr[@attr-name='ROLE']/add-value"/>

Is going to find all <add-value> elements which are children of modify-attr where @attr-name='ROLE'.

Anyway, I hope that helps.

cheers

Malcolm




-----Original Message-----
From: Vignesh Balan R [mailto:vigneshbr@xxxxxxxxxxxxxx]
Sent: Wednesday, September 25, 2002 1:38 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Copying XML tags into XSL variable - Urgent



Hi All

We have a XML file as the input , which would look like this,

<nds dtdversion="1.0" ndsversion="8.5" xmlns:jdbc="urn:dirxml:jdbc">
        <source>
                <product jdbc:build="20020215_1810"
jdbc:instance="JDBCdriver" version="1.5">DirXML Driver for
JDBC</product>
                <contact>Novell, Inc.</contact>
        </source>
        <input>
                <modify class-name="VIEW_INTMEDTAB"
event-id="modify:PK_ID=staff7,table=VIEW_INTMEDTAB,schema=OUHKDIRXML"
src-dn="PK_ID=staff7,table=VIEW_INTMEDTAB,schema=OUHKDIRXML">
                        <association
state="associated">PK_ID=staff7,table=VIEW_INTMEDTAB,schema=OUHKDIRXML</association>

                        <modify-attr attr-name="TYPEOFPOST">
                                <remove-all-values/>
                        </modify-attr>
                        <modify-attr attr-name="TYPEOFPOST">
                                <add-value>
                                        <value
type="string">Perm</value>
                                </add-value>
                        </modify-attr>
                        <modify-attr attr-name="LOGINNAME1">
                                <remove-all-values/>
                        </modify-attr>
                        <modify-attr attr-name="LOGINNAME1">
                                <add-value>
                                        <value
type="string">staff7</value>
                                </add-value>
                        </modify-attr>
                        <modify-attr attr-name="ROLE">
                                <remove-all-values/>
                        </modify-attr>
                       <modify-attr attr-name="ROLE">
                                <add-value>
                                        <value type="string">ole</value>

                                </add-value>
                                <add-value>
                                        <value
type="string">staffportal</value>
                                </add-value>
                        </modify-attr>
                        <modify-attr attr-name="OUTYPE">
                                <remove-all-values/>
                        </modify-attr>
                        <modify-attr attr-name="OUTYPE">
                                <add-value>
                                        <value
type="string">staff</value>
                                </add-value>
                        </modify-attr>
                        <modify-attr attr-name="INTPASSWORD">
                                <remove-all-values/>
                        </modify-attr>
                </modify>
        </input>
</nds>

>From the above XML i want to copy the following text
                "<modify-attr attr-name="ROLE">
                                <add-value>
                                        <value type="string">ole</value>

                                </add-value>
                                <add-value>
                                        <value
type="string">staffportal</value>
                                </add-value>
                        </modify-attr> "
into a variable in XSL. I want the whole thing to be stored as a
text(not only the parsed values, but all the tags too) in the variable.

I have tried the following using <xsl:apply-templates>.
<xsl::apply-templates
select="modify-attr[@attr-name='ROLE']/add-value"/>

But it doesnt copy the whole text, instead copies only the first
value("ole" in the above modify-attr).

Any pointers of how to do this, would be greatly appreciated.

Thanks and Regards
Vignesh

--
Early bird gets the worm ... Big Incentive !!


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.