|
next
|
 Subject: xsl:if always returns true when false Author: V NV Date: 16 Dec 2005 03:57 AM
|
Thanks for your suggestion. I will try to replace the "match template=*". My problem is, I have a schema containing hundreds of elements, and the xml file does not necessarily contain all the elements. Thats why I designed the template I'm using.
Using your approach, for all elements, I have to explicity add all the attrs of each element.
For ex: I my example, I need to write all attrs of <dad>, <member> <child> and <details> explicitly. Can I write a template, like "copy-as-it-is", which will copy all attrs of the element, without explicitly writing down each of them?
If I use the folowing xsl file:
<PLMXML>
<Header>
<xsl:call-template name="copy-as-it-is" />
</Header>
<ProductRevision>
<xsl:call-template name="copy-as-it-is" />
<Description>
<xsl:call-template name="copy-as-it-is" />
</Description>
<ApplicationRef>
<xsl:call-template name="copy-as-it-is" />
</ApplicationRef>
<AssociatedDataSet>
<xsl:call-template name="copy-as-it-is" />
</AssociatedDataSet>
</ProductRevision>
<Product>
<xsl:call-template name="copy-as-it-is" />
<Description>
<xsl:call-template name="copy-as-it-is" />
</Description>
<ApplicationRef>
<xsl:call-template name="copy-as-it-is" />
</ApplicationRef>
</Product>
<AccessIntent>
<xsl:call-template name="copy-as-it-is" />
</AccessIntent>
<Site>
<xsl:call-template name="copy-as-it-is" />
</Site>
<DataSet>
<xsl:call-template name="copy-as-it-is" />
<ApplicationRef>
<xsl:call-template name="copy-as-it-is" />
</ApplicationRef>
</DataSet>
<ExternalFile>
<xsl:call-template name="copy-as-it-is" />
<ApplicationRef>
<xsl:call-template name="copy-as-it-is" />
</ApplicationRef>
</ExternalFile>
</PLMXML>
</xsl:template>
<xsl:template name="copy-as-it-is" >
<xsl:element name="{name()}">
<xsl:for-each select="@*">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
, I get an error: "Output document cannot be parsed as xml: Expected element name". I see the output xml file as
<PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema">
<Header>
<#document/>
</Header>
<ProductRevision>
<#document/>
<Description>
<#document/>
</Description>
<ApplicationRef>
<#document/>
</ApplicationRef>
<AssociatedDataSet>
<#document/>
</AssociatedDataSet>
</ProductRevision>
<Product>
<#document/>
<Description>
<#document/>
</Description>
<ApplicationRef>
<#document/>
</ApplicationRef>
</Product>
<AccessIntent>
<#document/>
</AccessIntent>
<Site>
<#document/>
</Site>
<DataSet>
<#document/>
<ApplicationRef>
<#document/>
</ApplicationRef>
</DataSet>
<ExternalFile>
<#document/>
<ApplicationRef>
<#document/>
</ApplicationRef>
</ExternalFile>
</PLMXML>
which is wrong?
What is the problem with my template?
Regards,
|
|
|