View Single Post
Join Date: Dec 2008
Posts: 2
Reputation: vbhatia.81 is an unknown quantity at this point 
Solved Threads: 0
vbhatia.81 vbhatia.81 is offline Offline
Newbie Poster

PLMXML to generic xml

 
0
  #1
Dec 3rd, 2008
Hi I am new to xslt and i was trying to generate a generic xml from the plmxml.


Following is the plmxml.xml file
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema" schemaVersion="6" date="2008-12-02" time="15:33:22" author="Teamcenter V2007.1.3.20080417.00 - PLM@TCLICSRV(498908465)">
  4. <Product id="id2" name="Test" accessRefs="#id3" subType="Item" productId="000019"></Product>
  5. </PLMXML>
-------------------------------------------------------
And in the output i want <GXML> instead of <PLMXML>
and <Item> instead of <Product>
i.e my output xml should look like
<GXML>
<Item>
</Item>
</GXML>
-------------------------------------------------------


and following is my xslt but all i get is an empty file
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <?xml version='1.0'?>
  2.  
  3. <xsl:stylesheet
  4. version="1.0"
  5. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  6. xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema"
  7. xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema" exclude-result-prefixes="plm">
  8.  
  9. <xsl:strip-space elements="*" />
  10. <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
  11.  
  12. <xsl:template match="/">
  13. <xsl:variable name="elementName" select="name()"/>
  14. <xsl:choose>
  15. <xsl:when test="$elementName = 'PLMXML'">
  16. <xsl:call-template name="PLMXML"></xsl:call-template>
  17. </xsl:when>
  18. <xsl:when test="$elementName = 'Product'">
  19. <xsl:call-template name ="Item"></xsl:call-template>
  20. </xsl:when>
  21. </xsl:choose>
  22.  
  23. </xsl:template>
  24. <xsl:template name="PLMXML">
  25. <xsl:element name="GXML"></xsl:element>
  26. </xsl:template>
  27. <xsl:template name="Item">
  28. <xsl:element name="Item"></xsl:element>
  29. </xsl:template>
  30. </xsl:stylesheet>
and I am using msxsl Processor.

Can somone please help me understand where am i going wrong? All i could understand is there is some issues with namespace. I will be obliged is someone can shed more light on that or can correct my xslt.

Thanx in advance
Reply With Quote