Hello,
I just this question: -
<xsl:for-each select="//tag1">
-
<xsl:value-of select="text()" />
-
</xsl:for-each>
-
my output is:
hello;world;
I need:
Hello;
World;
my xslt header is: -
<xsl:output method="text"
-
encoding="iso-8859-1"
-
indent="yes"
-
My output file is a text file.....
How can I do this, please?
Best regards,
16 3888
You can concatenate text() with line feed entity "
". - <xsl:template match="/">
-
<xsl:for-each select="//tag1">
-
<xsl:value-of select="concat(text(), '
')"/>
-
</xsl:for-each>
-
</xsl:template>
hi thanks,
what do you think if I add it inside a text tag? is this better or not? - <xsl:text>>
</xsl:text>
sometimes I need to do this too: - <xsl:text>>printf("hello");
</xsl:text>
or indent the braces: - <xsl:text>> } 
</xsl:text>
What do you suggest for these aims?
Thanks,
I think it's absolutely normal, but variant with concatenation is more readable than your. Compare: -
<xsl:value-of select="concat( 'your_text', text(), '> } ', some_tag_value, 'your_text2')"/>
-
and -
<xsl:text>your_text</xsl:text><xsl:value-of select="text()/><xsl:text>> } </xsl:text><xsl:value-of select="some_attrib_value"/><xsl:text>your_text2</xsl:text>
-
thanks,
seem ok, but the function concat(), where I can find explanation about other function too?
Why doens't these below work? -
indent="yes"
-
xalan:indent-amount="2"/>
-
It's xalan specific instruction. I think U need to read some docs about it. )
Thanks; a further question if possible....
The text in the xml contains this string inside a tag: "hello\nworld" (and I mean not the new line but the '\' follow by 'n' -
<xsl:value-of select="concat( 'PRINT(', text(), ');' />
-
//produce in the output file:
-
PRINT(hello\nworld);
-
while I need in the output text file: -
PRINT(hello);
-
PRINT(world);
-
How can I do this, please?
<xsl:value-of select="concat( 'PRINT(',
replace(text(), '\n', 
),
');' />
<xsl:value-of select="concat( 'PRINT(',
replace(text(), '\n', 
),
');' />
hello,
it seems there's a problem to put the "(" ")" of replace inside a concat......Do you know it? Is there any trick, please?
thanks,
- <xsl:value-of select="concat( 'PRINT(',
-
replace(text(), '\n', ),
-
');' "/>
I forgot double quote at the end of "select" attribute. And you just need to pay attention to the code and read more docs ))
- <xsl:value-of select="concat( 'PRINT(',
-
replace(text(), '\n', ),
-
');' "/>
I forgot double quote at the end of "select" attribute. And you just need to pay attention to the code and read more docs ))
Hello, I don't understand: my code is this -
<xsl:value-of select="concat(' doc.print(',
-
replace(text(), '\n', '
' ), ');
');" disable-output-escaping="yes" />
-
now I'm editing it with .Net and it says that replace() isn't xslt function....
Is it ok ,please?
mm I haven't still done this thing; I can't understand how to do the replace() (in my case) with xslt 1.0....any suggests....
I remember...my output file output: -
print(hello\nworld); //"hello\nworld" is the result of text() xslt function
-
Instead I need: -
print(hello);
-
print(world);
-
That is: xslt should looks into text() and break the string when it sees a '\n';
thanks.
Could you post your input? It might really help to clear things up. I feel like we're forcing an error down a crooked path.
-
<root>
-
<htmltag><![CDATA[<html>\n<body>]]></htmltag>
-
<text><![CDATA[This is a text node]]></text>
-
<htmltag><![CDATA[.\n</body>\n</html>]]></htmltag>
-
</root>
-
This is my xml; with xalan and a xslt (as you read before) I have to produce: -
print(<html>);
-
print(<body>);
-
...................
-
at the moment it produce:
THe problem is that '\n' (and at this point the fact that xalan use xslt 1.0 and doens't know replace() )
Are you understand? I dont' understand how write the replace in xslt 1.0....
- <xsl:template name="globalReplace">
-
<xsl:param name="outputString"/>
-
<xsl:param name="target"/>
-
<xsl:param name="replacement"/>
-
<xsl:choose>
-
<xsl:when test="contains($outputString,$target)">
-
<xsl:text>print(<xsl:text>
-
<xsl:value-of select=
-
"concat(substring-before($outputString,$target),
-
$replacement)"/>
-
<xsl:text>);<xsl:text>
-
<xsl:call-template name="globalReplace">
-
<xsl:with-param name="outputString"
-
select="substring-after($outputString,$target)"/>
-
<xsl:with-param name="target" select="$target"/>
-
<xsl:with-param name="replacement"
-
select="$replacement"/>
-
</xsl:call-template>
-
</xsl:when>
-
<xsl:otherwise>
-
<xsl:text>print(<xsl:text>
-
<xsl:value-of select="$outputString"/>
-
<xsl:text>);<xsl:text>
-
</xsl:otherwise>
-
</xsl:choose>
-
</xsl:template>
-
Put the corresponding print text around anywhere where you output the text.
target is '\n', replacement is '' (empty string)
hello,
there is a problem: $outputString; I suppose I have to set this via Xalan (in java code); but as you can see in my previous code I use text();
With xalan I can do :
trasformer.setParameter("target", '\n' );
trasformer.setParameter("replacement", "" );
but only this and not other...
Are you understand, plese?
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
5 posts
views
Thread by Marcel |
last post: by
|
1 post
views
Thread by Spam sucks |
last post: by
|
3 posts
views
Thread by Tjerk Wolterink |
last post: by
|
3 posts
views
Thread by Tjerk Wolterink |
last post: by
|
2 posts
views
Thread by Dirk McCormick |
last post: by
|
3 posts
views
Thread by rene |
last post: by
|
reply
views
Thread by George Durzi |
last post: by
|
5 posts
views
Thread by nutsmuggler |
last post: by
|
2 posts
views
Thread by Andrus |
last post: by
| | | | | | | | | | |