Jump to content

Recommended Posts

Hi everyone

as I don't think I'll ever figure this out on my own (even with all the doc I read), please tell me what I do wrong, even if it is strictly speaking a xslt-problem. But as XMLSpy evaluates my XPath how I want it to, but not  the built-in XSLT-processor in 5.2.6-2ubuntu4.1...:

I've got a html-fragment like this:

<h5><b>Art. 1</b> Persoenlicher Geltungsbereich</h5>

As result of the transformation I'd like to have something as:

<articleMetadata>
<articleNumber>Art. 1</articleNumber>
<articleHeader><text>
Persoenlicher Geltungsbereich
</text></articleHeader>

I try to achieve this by using:

<xsl:template match="h5">
	<articleMetadata>
		<xsl:apply-templates select="b"/>
		<articleHeader><text>
			<xsl:value-of select="text()"/>
		</text></articleHeader>
	</articleMetadata>
</xsl:template>
<!-- Artikelnummer -->	
<xsl:template match="b">
	<articleNumber>
		<xsl:value-of select="."/>
	</articleNumber>
</xsl:template>

Unfortunately, text() only gives me an empty string. If I try out the full XPath in XMLSpy, text() points me to "Persoenlicher Geltungsbereich".

 

What don't I understand? Thanks for your help!

Daniel

Thanks for the answer and sorry for posting to the wrong forum!

 

Looks fine to me.  How do you know it's blank?

When I do a

$domart = $procart->transformToDoc($docart);
echo htmlentities($domart->saveXML());

all I get is

<articleMetadata>
  <articleNumber>Art. 1</articleNumber>
  <articleHeader><text> </text></articleHeader>
</articleMetadata>

 

Try hard-coding some text: ...

This indeed gives me "text :" in the transformed DOM

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.