|
-
July 24th, 2008, 12:01 PM
#1
Difficulty with XSLT
I'm trying to convert an xml document into another xml document.
The original xml file has a structure that looks like this:
<securitydefinition attr1="1" attr2="2" ... >
<keysets>
<key>...</key>
...
</keysets>
<fields>
<field a1="1" ... >...</field>
...
</fields>
</securitydefinition>
I'm looking to pull out the attributes of each field element. This is my xslt code and it just does not want to find the fields element. It just spits out all the non-element tagged text between the <hibernate-mapping> tags. If I add select="fields" to the apply-templates tag, I just get an empty <hibernate-mapping> tag. Any help would be appreciated.
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" />
<xsl:template match="/">
<hibernate-mapping>
<xsl:apply-templates />
</hibernate-mapping>
</xsl:template>
<xsl:template match="fields">
<xsl:value-of select="@security_id" />
<xsl:for-each select="field">
<xsl:call-template name="field" />
</xsl:for-each>
</xsl:template>
<xsl:template name="field">
<property></property>
</xsl:template>
</xsl:stylesheet>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|