XSL: inline tags

X

Xtr

Hello,

Is it possible, using xsl, to indent most tags, but preserve the
position of tags that are inline (surrounded by text)?

For example, given the following,:

<text><p>text<b>text</b></p></text>
<text><p>text<b>text</b></p></text>

have it output like this:

<text>
<p>text<b>text</b></p>
</text>
<text>
<p>text<b>text</b></p>
</text>

Can this, for example, be done by using indent="yes" and using some
kind of exception for certain tags?

Thanks.
 
M

Martin Honnen

Xtr said:
Is it possible, using xsl, to indent most tags, but preserve the
position of tags that are inline (surrounded by text)?

For example, given the following,:

<text><p>text<b>text</b></p></text>
<text><p>text<b>text</b></p></text>

have it output like this:

<text>
<p>text<b>text</b></p>
</text>
<text>
<p>text<b>text</b></p>
</text>

Can this, for example, be done by using indent="yes" and using some
kind of exception for certain tags?

If you use indent yes and <xsl:eek:utput method="html"> then the XSLT
processor usually does try to keep text in HTML containers like <p> ir
HTML inline elements like <b> as it is output in the result elements.
With output method xml it is usually not clear to a processor what the
semantics of your <p> or <b> elements is.
 
X

Xtr

Martin Honnen said:
If you use indent yes and <xsl:eek:utput method="html"> then the XSLT
processor usually does try to keep text in HTML containers like <p> ir
HTML inline elements like <b> as it is output in the result elements.
With output method xml it is usually not clear to a processor what the
semantics of your <p> or <b> elements is.

I need to output to plain XML. What would solve my problem would be a
way to specify certain element-types that should always be inline
within the parent element.

I guess it would be possible to create a "function" in XSLT that
parses every element and indents the element based on its position or
"layer" within the xml-file. This function would then indent some
elements and put some inline.

However, if it is possible to use indent="yes", I would rather like to
do that to keep things simple.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top