BlazBlader
New Member
I'm an absolute beginner and any help is greatly appreciated.I'm trying to transform XML to XML. Here's an example of a starting XML document:\[code\]<document><p>Name: John Smith</p><p>Gender: Male</p><p>Hometown: Dallas</p><p>Bio: A lot of info goes here.</p><p>Name: Jane Doe</p><p>Gender: Female</p><p>Hometown: Chicago</p><p>Bio: Here is a sentence of information.</p></document>\[/code\]Here's what I'm struggling with:\[code\]<xsl:template match="document/p"><entry><xsl:element name="{substring-before(string(.),':')}"><xsl:apply-templates/></xsl:element></entry></xsl:template>\[/code\]I'm wondering if I have incorrect syntax in the name attribute of the new element? Or am I trying to do something and not going about it the correct way? If I put in literal text like name="info" The resulting XML is just as good as my original XML instead of \[code\]<p>\[/code\]each element is \[code\]<info>\[/code\]I'd like to have the transformed XML look like this and basically use whatever precedes the colon as the name of the element:\[code\]<Name>John Smith</Name><Hometown>Dallas</Hometown>etc.\[/code\]I'm very open to different ways to accomplish this and appreciate any guidance since I am brand new to XSLT.Thanks!