dare Posted June 11, 2009 Share Posted June 11, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/161848-solved-xpath-xslt-issue-why-dont-i-get-the-text/ Share on other sites More sharing options...
Maq Posted June 11, 2009 Share Posted June 11, 2009 Looks fine to me. How do you know it's blank? Try hard-coding some text: text: Quote Link to comment https://forums.phpfreaks.com/topic/161848-solved-xpath-xslt-issue-why-dont-i-get-the-text/#findComment-853913 Share on other sites More sharing options...
dare Posted June 11, 2009 Author Share Posted June 11, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/161848-solved-xpath-xslt-issue-why-dont-i-get-the-text/#findComment-854039 Share on other sites More sharing options...
dare Posted June 12, 2009 Author Share Posted June 12, 2009 Ok, got it myself - the error was using <xsl:value-of select="text()"/> instead of <xsl:copy-of select="text()"/> Quote Link to comment https://forums.phpfreaks.com/topic/161848-solved-xpath-xslt-issue-why-dont-i-get-the-text/#findComment-854297 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.