|
Subject: [xsl] Getting all the text of an element, except for one type From: "rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 9 Feb 2024 13:57:10 -0000 |
Hi All. Here is my input:
<?xml version="1.0" encoding="UTF-8"?>
<pub>
<section>
<title>This is my clever title with <ph>a phrase</ph> and some
data.<data>12345</data></title>
<p>A plain paragraph.</p>
</section>
<section>
<title>Another title without any children.</title>
<p>Another plain paragraph.</p>
</section>
</pub>
I want to get all of the text from the <title> elements are its children,
except for <data> elements:
<?xml version="1.0" encoding="UTF-8"?>
<pub>
<entry>This is my clever title with a phrase and some data. </entry>
<entry>Another title without any children.</entry>
</pub>
Here is my stylesheet but I am missing something in my understanding. Thanks
in advance for your help.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
exclude-result-prefixes="xs math"
version="3.0" expand-text="yes">
<xsl:output indent="yes"/>
<xsl:template match="/pub">
<xsl:copy>
<xsl:apply-templates select="section"/>
</xsl:copy>
</xsl:template>
<xsl:template match="section">
<entry><xsl:value-of select="title/descendant-or-self::* except
data"/></entry>
</xsl:template>
</xsl:stylesheet>
Rick
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Find several different at, Andre Cusson akhu01@ | Thread | Re: [xsl] Getting all the text of a, Martin Honnen martin |
| Re: [xsl] Find several different at, Andre Cusson akhu01@ | Date | Re: [xsl] Getting all the text of a, Martin Honnen martin |
| Month |