[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] XSLT problem
Subject: [xsl] XSLT problem From: "Houman Khorasani" <Houman.Khorasani@xxxxxxxxxxx> Date: Mon, 18 Aug 2008 14:20:49 +0100 |
Hello Everyone, I am doing some XSLT to get this little piece of work done. I am kind of stuck and was hoping you could help me out. Input XML: <Civ4ArtDefines xmlns="x-schema:CIV4ArtDefinesSchema.xml"> <UnitArtInfos> <UnitArtInfo> <Type>ART_DEF_UNIT_LION</Type> <fScale>0.61</fScale> </UnitArtInfo> <UnitArtInfo> <Type>ART_DEF_UNIT_ZEPPELIN</Type> <fScale>0.70</fScale> </UnitArtInfo> </UnitArtInfos> </Civ4ArtDefines> Only Certain units (e.g. Zeppelin) should be extracted and rest (e.g. Lion) should be ignored. The actual information for the "Button" for Zeppelin is stored inside my XSLT. Expected Output XML: <Civ4ArtDefines xmlns="x-schema:CIV4ArtDefinesSchema.xml"> <UnitArtInfos> <UnitArtInfo> <Type>ART_DEF_UNIT_ZEPPELIN</Type> <Button>Art/Interface/Buttons/Units/Zeppelin.dds</Button> <fScale>0.70</fScale> </UnitArtInfo> </UnitArtInfos> </Civ4ArtDefines> With the XSLT below I only see an empty Button XML element in the correct position. My condition somehow doesn't pick it up. Would be great if you could help me out with this one. Many thanks XSLT: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="x-schema:CIV4ArtDefinesSchema.xml" exclude-result-prefixes="a" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <UnitInfos xmlns="x-schema:CIV4ArtDefinesSchema.xml"> <Unit> <Type>ART_DEF_UNIT_ZEPPELIN</Type> <Button>Art/Interface/Buttons/Units/Zeppelin.dds</Button> </Unit> </UnitInfos> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="a:fScale"> <xsl:element name="Button" namespace="x-schema:CIV4ArtDefinesSchema.xml"> <xsl:value-of select="document('')/xsl:stylesheet/a:UnitInfos/a:Unit/a:Button[ancestor ::a:Type = document('')/xsl:stylesheet/a:UnitInfos/a:Unit/a:Type]"/> </xsl:element> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Display count function ou, Florent Georges | Thread | Re: [xsl] XSLT problem, Martin Honnen |
Re: [xsl] Display count function ou, Florent Georges | Date | [xsl] flattening and re-ordering ne, Walter Lee Davis |
Month |