 |
 |
 |
Rasheed wrote:
> <xsl:apply-templates select="Employee"/>
> //Here I have transfer only single Employee node and I want to iterate
> all the nodes in single employee and check a perticular node and do
> some operations. Like below.
>
> <xsl:template match=" Employee ">
> <xsl:choose>
> <xsl:when test="name">
> <xsl:element name="EmpName">
> <xsl:value-of select="name"/>
> </xsl:element>
> </xsl:when>
> </xsl:choose>
> Copy rest of the nodes here.
> </xsl:template>
Just use the two templates I have posted, that way all elements are
copied, only the Name child of Employ is changed.
> 1) <xsl:apply-templates select=" "/> :
> a. if am using "apply-templates" statement then my output was like
> below (this is like my final structure with no data). I don't know why
> this happened in my prog.
> <Employ> </Employ>
> <Dept> </ Dept >
I don't understand what <xsl:apply-templates select=" "/> would be good
for, you either need to have <xsl:apply-templates/> with no select
attribute or you need to select nodes, an empty select attribute value
does not make sense.
> 2) I have read about <xsl:copy> is not using then result will be in
> different way. Is this in my case because I am not using <xsl:copy> ?
I don't understand that either, so far I think your problem can be
solved with the two templates I posted.
> 3) i have got some value like this:
> <xsl:template match="instance">
> <!-- <xsl:copy-of select="instance"/> -->
> <xsl:element name ="instance">
> <xsl:value-of select="."/>
> </xsl:element>
> </xsl:template>
> so I want to change my statements like this
> If(<xsl:value-of select="."/> != "")
> {
> //Create Element "instance node "
> <xsl:element name ="instance">
> <xsl:value-of select="."/>
> </xsl:element>
>
> }
> becase if <xsl:value-of select="."/> value is null even i am creating
> a node with null string so i have to avoid this case.
> So how can I go about in this case. If I stored "select="."" value in
> a variable and I can check it. But in my prog I had many statement
> like this. for all statements I would create variables ? I hope its
> not good way.
You can write templates for those elements that have contents e.g.
<xsl:template match="instance[text()]">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
and add another one doing nothing for those that do not have contents:
<xsl:template match="instance[not(text())]"/>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
|
 | 



|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |