canyou solve this prob, i wt to remove specific type element
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Fri Jan 18, 2008 12:15 pm
- Location: Bangalore
canyou solve this prob, i wt to remove specific type element
Post by amitsaini54 »
Hi all
Any body is there who can help me….
I have xml file…..
<Project>
<Body>
<TXT><TXT>
<TXT>Hello TXT <TXT>
<Model><Model>
<Model>hello model<Model>
<Body>
</Project>
In this xml file two TXT element one is empty & other has value
I want to remove the empty elpement…
want the output like this
<Project>
<Body>
(don’t want TXT element)
<TXT>Hello TXT <TXT>
<Model><Model>
<Model>hello model<Model>
<Body>
</Project>
I wrote one xslt file
Like this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:if test=". != '' ">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
By this xslt , I got the output like this
<Project>
<Body>
<TXT>Hello TXT <TXT>
<Model>hello model<Model>
<Body>
</Project>
This xslt file remove both empty element “<TXT>â€,â€<Model>â€
But I want to remove only one <TXT>
Help me….please
Any body is there who can help me….
I have xml file…..
<Project>
<Body>
<TXT><TXT>
<TXT>Hello TXT <TXT>
<Model><Model>
<Model>hello model<Model>
<Body>
</Project>
In this xml file two TXT element one is empty & other has value
I want to remove the empty elpement…
want the output like this
<Project>
<Body>
(don’t want TXT element)
<TXT>Hello TXT <TXT>
<Model><Model>
<Model>hello model<Model>
<Body>
</Project>
I wrote one xslt file
Like this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:if test=". != '' ">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
By this xslt , I got the output like this
<Project>
<Body>
<TXT>Hello TXT <TXT>
<Model>hello model<Model>
<Body>
</Project>
This xslt file remove both empty element “<TXT>â€,â€<Model>â€
But I want to remove only one <TXT>
Help me….please
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
You can inhibit the output for the empty TXT element by writing an empty template maching it. The rest of the nodes are copied by the less prioritary second template.
A good XSL tutorial: http://www.zvon.org/xxl/XSLTutorial/Boo ... index.html
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="TXT[count(node()) = 0]"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
-
- Posts: 2
- Joined: Fri Jan 18, 2008 12:15 pm
- Location: Bangalore
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service