Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
XML
XML to XML newbee help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Andy Dingley, post: 773414"] Try this: Notes: - I'm ingnoring some whitespace issues that are rarely significant. You'd need to supply a better spec before going there. - I guess the text of the second link in your example was a typo. - This is an impossible problem to solve, as a general case from one example. I can make it work (quite easily) for that one case, but a couple of examples don't _define_ a mapping (I had to guess at this, and it's a 50:50 guess between whether to map <item> or <par class="MainText"> as the output <para>). As a reductio ad absurdum, I could simply have wrapped your output example in a <xsl:template> element (literal text and all !) and called that a valid solution to the stated question. You see the problem ? <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="[URL]http://www.w3.org/1999/XSL/Transform[/URL]" xmlns:xlink="[URL]http://www.w3.org/1999/xlink[/URL]" exclude-result-prefixes="xlink" <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="link" > <link href="{@xlink:href}" ><xsl:value-of select=".//text()" /></link> </xsl:template> <xsl:template match="par[@class='Normal']" /> <xsl:template match="par[@class='MainText']" > <para> <xsl:value-of select="translate (parent::item/@numberingtext, ' ', ' ')" /> <xsl:apply-templates select="* | text()" /> </para> </xsl:template> <xsl:template match="par[@class and not (@class = 'Normal' or @class = 'MainText')]" > <xsl:element name="{./@class}" ><xsl:value-of select="text()" /></xsl:element> </xsl:template> <xsl:template match="document/part" > <root> <xsl:apply-templates select="*" /> </root> </xsl:template> </xsl:stylesheet> [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
XML
XML to XML newbee help
Top