generate xml from xsl using xsl v2

Dear all,
I use this <xsl:template name="ignorewhatever" match="template[state = 1]" > 
to select template with state =1
how to select state =1 and template/template_type[type_id=1 ??
Also need to wrapper the xml output with <ROOT>
thanks
ethar1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
to wrap the XML output with ROOT

<xsl:template match="/">
<ROOT>
<xsl:apply-templates/>
</ROOT>
</xsl:template>

and the other test
<xsl:template name="ignorewhatever" match="template[state = 1][template_type[type_id=1]]" >
0
ethar1Author Commented:
<xsl:template match="/">
 
<ROOT>

<xsl:template match="template[not(state = 1)]"/>


</ROOT>
</xsl:template>

give an error
0
ethar1Author Commented:
I think  this expression has a problem
match="template[state = 1][template_type[type_id=1]]"
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Geert BormansInformation ArchitectCommented:
The expression does not have a problem.
You made a copying error,
you can't have a template nested inside a template
look at what I posted and what you made from it
0
ethar1Author Commented:
ok, what about this
<xsl:template match="template[not(state = 1)][ template_type[not(type_id=24)]]"/>
0
Geert BormansInformation ArchitectCommented:
seems a valid XPath expression
Of course, I have no idea what the source XML is
0
ethar1Author Commented:
	<template id="47253">
		<id>47253</id>
		<state>1</state>
		<price>75</price>
		<exc_price>4500</exc_price>
		<downloads>1</downloads>
		<is_flash>0</is_flash>
		<is_adult>0</is_adult>
		<is_full_site>0</is_full_site>
		<inserted_date>2013-11-05 00:00:00</inserted_date>
		<update_date>2013-11-25 21:33:32</update_date>
		<width>1680px</width>
		<is_real_size>1</is_real_size>
		<template_type>
			<type_id>24</type_id>
			<type_name>Joomla Templates</type_name>
		</template_type>
		<author>
			<author_id>247</author_id>
			<author_nick>Jenny</author_nick>
		</author>
		<live_preview_url>joomla_47253</live_preview_url>
		<package>
			<package_id>248</package_id>
		</package>
		<properties>
			<property>
				<propertyName>Features</propertyName>
				<propertyValues>
					<propertyValue>Admin Panel</propertyValue>
					<propertyValue>Responsive</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>Animation</propertyName>
				<propertyValues>
					<propertyValue>HTML plus JS</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>Functionality</propertyName>
				<propertyValues>
					<propertyValue>blog</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>Layout</propertyName>
				<propertyValues>
					<propertyValue>2 columns</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>livePreviewURL</propertyName>
				<propertyValues>
					<propertyValue>joomla_47253</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>width</propertyName>
				<propertyValues>
					<propertyValue>1680px</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>Language support</propertyName>
				<propertyValues>
					<propertyValue>English</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>joomla-engine</propertyName>
				<propertyValues>
					<propertyValue>2.5.9</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>joomla-compatibility</propertyName>
				<propertyValues>
					<propertyValue>2.5.9</propertyValue>
					<propertyValue>2.5.8</propertyValue>
					<propertyValue>2.5.7</propertyValue>
				</propertyValues>
			</property>
			<property>
				<propertyName>Installation</propertyName>
				<propertyValues>
					<propertyValue>Installation and set up instructions are attached (look for Documentation folder).</propertyValue>
				</propertyValues>
			</property>
		</properties>
		<screenshots_list>
			<screenshot>
				<uri>47200/47253-joom-b-p.jpg</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-rs.jpg</uri>
				<filemtime>2013-10-31 05:10:15</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-joom-b.jpg</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
				<main_preview>1</main_preview>
			</screenshot>
			<screenshot>
				<uri>47200/47253-banner.jpg</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-origin.jpg</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-original-1200.jpg</uri>
				<filemtime>2013-10-31 05:10:15</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-modules.jpg</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-m.jpg</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
				<small_preview>1</small_preview>
			</screenshot>
			<screenshot>
				<uri>47200/47253-origin-1200.jpg</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-smart1-responsive.jpg</uri>
				<filemtime>2013-10-31 05:10:15</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-big.jpg</uri>
				<filemtime>2013-11-22 10:11:28</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-tablet-responsive.jpg</uri>
				<filemtime>2013-10-31 05:10:15</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-med.jpg</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-smart2-responsive.jpg</uri>
				<filemtime>2013-10-31 05:10:15</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-joom.html</uri>
				<filemtime>2013-10-31 05:10:14</filemtime>
			</screenshot>
			<screenshot>
				<uri>47200/47253-original.jpg</uri>
				<filemtime>2013-10-31 05:10:15</filemtime>
			</screenshot>
		</screenshots_list>
		<keywords>yoga studio club health body mind spirit stress specials services announcement benefits classes practice hatha kripalu yoga basics pilates ashtanga &amp;amp; anusara pre-natal specialized karma teacher training iyengar kids yoga meditation therapeutic</keywords>
		<styles/>
		<categories>
			<category>
				<category_id>14</category_id>
				<category_name>Sport</category_name>
			</category>
		</categories>
		<sources_available_list>
			<source>
				<source_id>3</source_id>
			</source>
			<source>
				<source_id>12</source_id>
			</source>
		</sources_available_list>
		<sources> .PSD&lt;br&gt;.PHP</sources>
		<software_required_list>
			<software>
				<software_id>8</software_id>
			</software>
			<software>
				<software_id>26</software_id>
			</software>
			<software>
				<software_id>53</software_id>
			</software>
			<software>
				<software_id>238</software_id>
			</software>
		</software_required_list>
		<software_required> Adobe Photoshop CS+; Adobe Dreamweaver 8+ (or any php-editor); For uncompressing a template ZIP package:&lt;br&gt; WinZip 9+ (Windows);&lt;br&gt; Stuffit Expander 10+ (Mac); Joomla! 2.5.9</software_required>
		<pages>
			<page>
				<name>Main Page</name>
				<screenshots>
					<scr>
						<description>Real Size Screenshot</description>
						<uri>47200/47253-rs.jpg</uri>
						<scr_type_id>78</scr_type_id>
						<width>970</width>
						<height>280</height>
						<href/>
					</scr>
					<scr>
						<description/>
						<uri>47200/47253-joom.html</uri>
						<scr_type_id>179</scr_type_id>
						<width>430</width>
						<height>60</height>
						<href/>
					</scr>
					<scr>
						<description>Joomla Main Page preview</description>
						<uri>47200/47253-joom-b.jpg</uri>
						<scr_type_id>178</scr_type_id>
						<width>430</width>
						<height>376</height>
						<href/>
					</scr>
					<scr>
						<description>Joomla Modules Positions</description>
						<uri>47200/47253-joom-b-p.jpg</uri>
						<scr_type_id>182</scr_type_id>
						<width>430</width>
						<height>376</height>
						<href/>
					</scr>
					<scr>
						<description>Tablet Layout </description>
						<uri>47200/47253-tablet-responsive.jpg</uri>
						<scr_type_id>298</scr_type_id>
						<width>430</width>
						<height>574</height>
						<href/>
					</scr>
					<scr>
						<description>Smartphone Layout 1 </description>
						<uri>47200/47253-smart1-responsive.jpg</uri>
						<scr_type_id>299</scr_type_id>
						<width>430</width>
						<height>900</height>
						<href/>
					</scr>
					<scr>
						<description>Smartphone Layout 2</description>
						<uri>47200/47253-smart2-responsive.jpg</uri>
						<scr_type_id>300</scr_type_id>
						<width>320</width>
						<height>900</height>
						<href/>
					</scr>
				</screenshots>
			</page>
		</pages>
		<basic_colors>
			<red>0</red>
			<orange>1</orange>
			<yellow>32</yellow>
			<green>38</green>
			<cyan>126</cyan>
			<blue>21</blue>
			<pink>56</pink>
			<purple>50</purple>
			<brown>2</brown>
			<grey>190</grey>
			<white>231</white>
			<black>19</black>
		</basic_colors>
		<colors_mixes>
			<cyan>126</cyan>
			<cyan_grey>23940</cyan_grey>
			<cyan_grey_pink>1340640</cyan_grey_pink>
			<cyan_grey_purple>1197000</cyan_grey_purple>
			<cyan_grey_white>5530140</cyan_grey_white>
			<cyan_pink>7056</cyan_pink>
			<cyan_pink_purple>352800</cyan_pink_purple>
			<cyan_pink_white>1629936</cyan_pink_white>
			<cyan_purple>6300</cyan_purple>
			<cyan_purple_white>1455300</cyan_purple_white>
			<cyan_white>29106</cyan_white>
			<grey>190</grey>
			<grey_pink>10640</grey_pink>
			<grey_pink_purple>532000</grey_pink_purple>
			<grey_pink_white>2457840</grey_pink_white>
			<grey_purple>9500</grey_purple>
			<grey_purple_white>2194500</grey_purple_white>
			<grey_white>43890</grey_white>
			<pink>56</pink>
			<pink_purple>2800</pink_purple>
			<pink_purple_white>646800</pink_purple_white>
			<pink_white>12936</pink_white>
			<purple>50</purple>
			<purple_white>11550</purple_white>
			<white>231</white>
		</colors_mixes>
	</template>

Open in new window

0
Geert BormansInformation ArchitectCommented:
well, I am not sure whether that helps

Here is an XSLT that wraps your root around the result.
But I have no clue of what else you are trying to do.
Your example has only one template, so what is there to filter.
Please try to explain clear and concise what exactly you need beside the wrapping

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    
    <xsl:strip-space elements="*"/>
    <xsl:output indent="yes"/>
    
    <xsl:template match="/">
        <ROOT>
            <xsl:apply-templates select="node()"/>
        </ROOT>
    </xsl:template>
    
    <xsl:template match="node()">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
    
</xsl:stylesheet>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.