Hello,
I'm unsing well-formed XML HTML tags as my formatted "Description"
content in a XML Database, so I have stuff of the sort:
<Description lang='en'><b>This is bold Text</band this is not<i>and
this is italic text</i></Description>
So far, nothing too dramatic, when I want to reproduce this as an HTML
output, I used the <xsl:copy-ofcommand to copy the whole node over
to my HTML output.
Now here comes where I have an issue:
I want to use a specific tag <spec name='specname'/to insert
"Specifications" related to the product WITHIN the formatted text...
so it could be anywhere under <Descriptionor a <btag, or a <i>
tag ...
The idea is that products are built out of other products, and I want
to be able to have the specification propagate through to the higher
level products, so I only want to "reference" the spec name in the
Description, and pull it out from the lower level product at the time
of output.
So, my problem is to "fill in" my <spec name='specname'/tag with its
content coming from somewhere else.
The <xsl:copy-ofcan no longer be used here, and it doesn't do the
job, but then is there an easy way to "transfer" all of the XML/HTML
and just replace the tag i want to replace?
I obviously need to parse the whole thing, but tags can be anything,
anywhere, (from the selection of formatting tags <b>, <i>, <u>, <br/>,
<p>, <sub>, <supetc...)
I'm not so proficient in XPath to figure out what would be the path I
want to select to transfer all tags but my <spectag, and when
bumping into one, replacing it with my data.
any insight?
Suggestion appreciated!
Thanks 3 2151
I tried this:
<xsl:template match="@* | node()">
<xsl:choose>
<xsl:when test="@name">
print Spec here
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
and it works fine, but I am not sure why the following doesn't:
<xsl:template match="@* | node()">
<xsl:choose>
<xsl:when test="spec">
print Spec here
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
ideally I need to process more than 1 attribute from the <spectag,
so i'd like to trigger it on that node name, not on the attribute
any idea?
Wizfrog wrote:
I tried this, but it always seem to use the @* | node() by default,
and never gets to the match='spec[...]' template even when getting to
a <spectag...
In that case, the spec element isn't matching. Either the predicate is
wrong or you've got namespaces involved. Think about why, or give us
enough information to diagnose.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Wizfrog wrote:
<xsl:when test="@name">
True when the current node has a name attribute, ie the <spec>.
<xsl:when test="spec">
True when the current node has a spec element child, ie the <spec>'s
parent.
xsl:when is not the best way to do this -- use templates -- but if you
must, you could try
<xsl:when test="self::spec">
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ralf Wahner |
last post by:
Dear Masters of XSLT
Could I ask you for a clue on the following question? I'd
like to use XSLT to transform an XML source file to LaTeX.
In the following small example the <para> Element...
|
by: Erhard Schwenk |
last post by:
Hi there,
Maybe this is a faq, if so, point me the URL please.
I have to do some xml to xml transformations in xslt, where I have -
simplified - the following:
input:
<doc>...
|
by: Johannes Lebek |
last post by:
Hi there,
somehow, I cannot access nodes that are stored in a variable. I'm using
Xalan 2.5.1 and the following commands:
================ BEGIN ====================
<xsl:variable...
|
by: Rolf Kemper |
last post by:
Dear Experts,
I got stuck with the following problem and need your help.
What I wnat to do is to get a set of distinct nodes.
Before the distinct I have selected the multiple occourences...
|
by: Claudio Jolowicz |
last post by:
How can XSLT stylesheets be used to edit, remove and add nodes specified
by their position in the document tree?
The XML document stores development tasks in a hierarchical way, i.e.
tasks can...
| |
by: Chris |
last post by:
I have a problem with grouping elements in my XSL. What I want to do
is select all of the distinct SCE_CGPC records, then by the FSG_SNAM
records for each SCE_CGPC and then again by MOA_NAME for...
|
by: JJ |
last post by:
I need to basically copy an entire XML document to another XML document.
The first needs to be an exact copy of the second, and I need to do it a
node at a time as I am omitting certain nodes...
|
by: tschwartz |
last post by:
I'm trying to write a stylesheet which removes nodes which are empty
as a result of other template processing.
For example, given the following xml, I'd like to:
- remove all "b" elements
-...
|
by: milecimm |
last post by:
Hello, I need some help to solve the following problem (if it is possible, that's it):
I'm using a xpath expression to programatically get data from my xml file. I want to transform ONLY the...
|
by: blackirish |
last post by:
Hi all,
I am trying to merge 2 XML files that first of all i need to compare nodes of both files according to 2 attributes in the nodes. If those 3 attributes are equal, i need to replace the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |