Exact copy of 1 line
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 9
- Joined: Fri Jan 30, 2009 6:57 pm
Exact copy of 1 line
I have this:
<ElA>

<SubElA><SubSubElA>someText</SubSubElA>someText<SubSubElB> some text</SubSubElB></SubElA>

</ElA>
I want to copy this in a new XML like this (on 1 line !):
<SubElA><SubSubElA>someText</SubSubElA>sometText<SubSubElB>someText</SubSubElB></SubElA>
Unfortunately I receive this (multiple lines):
<SubElA>
<SubSubElA>someText</SubSubElA>someText<SubSubElB>someText</SubSubElB>
</SubElA>
I need to have everything on 1 line.
I use this in my XSL:
<xsl:template match="ElA">
<xsl:apply-templates select="node()" mode="clone"/>

</xsl:template>


<xsl:template match="@*|node()" mode="clone">

<xsl:copy>

<xsl:apply-templates select="@*|node()" mode="clone"/>

</xsl:copy>

</xsl:template>

Is there another method to do this,
Any help is very appreciated.
Kind Regards,
Droom
<ElA>

<SubElA><SubSubElA>someText</SubSubElA>someText<SubSubElB> some text</SubSubElB></SubElA>

</ElA>
I want to copy this in a new XML like this (on 1 line !):
<SubElA><SubSubElA>someText</SubSubElA>sometText<SubSubElB>someText</SubSubElB></SubElA>
Unfortunately I receive this (multiple lines):
<SubElA>
<SubSubElA>someText</SubSubElA>someText<SubSubElB>someText</SubSubElB>
</SubElA>
I need to have everything on 1 line.
I use this in my XSL:
<xsl:template match="ElA">
<xsl:apply-templates select="node()" mode="clone"/>

</xsl:template>


<xsl:template match="@*|node()" mode="clone">

<xsl:copy>

<xsl:apply-templates select="@*|node()" mode="clone"/>

</xsl:copy>

</xsl:template>

Is there another method to do this,
Any help is very appreciated.
Kind Regards,
Droom
-
- Site Admin
- Posts: 2096
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Exact copy of 1 line
I cannot reproduce that. For me
with
gives (with the content on a single line, this may wrap in the browser):
What XSLT processor are you using?
Regards,
George
Code: Select all
<ElA>
<SubElA><SubSubElA>someText</SubSubElA>someText<SubSubElB> some text</SubSubElB></SubElA>
</ElA>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="ElA">
<xsl:apply-templates select="node()" mode="clone"/>
</xsl:template>
<xsl:template match="@*|node()" mode="clone">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="clone"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<SubElA><SubSubElA>someText</SubSubElA>someText<SubSubElB> some text</SubSubElB></SubElA>
Regards,
George
George Cristian Bina
-
- Posts: 9
- Joined: Fri Jan 30, 2009 6:57 pm
Re: Exact copy of 1 line
george,
(already thanks for your time)
When I use this header I have everything on 1 line:
<?xml version="1.0" encoding="ISO-8859-15" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" method="xml"/>
But I only want to copy some lines, which where originaly on 1 line, to 1 line.
Right now I'm using this header:
<?xml version="1.0" encoding="ISO-8859-15" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" method="xml" indent="yes" />
I hope I'm clear anough ?
Kind Regards,
Droom
(already thanks for your time)
When I use this header I have everything on 1 line:
<?xml version="1.0" encoding="ISO-8859-15" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" method="xml"/>
But I only want to copy some lines, which where originaly on 1 line, to 1 line.
Right now I'm using this header:
<?xml version="1.0" encoding="ISO-8859-15" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" method="xml" indent="yes" />
I hope I'm clear anough ?
Kind Regards,
Droom
-
- Site Admin
- Posts: 2096
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Exact copy of 1 line
Hi Droom,
When you specify indent="yes" you tell the XSLT processor to try to indent your file and the behaviour is very much processor dependent so you should use that only if you do not care too much about the indentation.
Best Regards,
George
When you specify indent="yes" you tell the XSLT processor to try to indent your file and the behaviour is very much processor dependent so you should use that only if you do not care too much about the indentation.
Best Regards,
George
George Cristian Bina
-
- Posts: 9
- Joined: Fri Jan 30, 2009 6:57 pm
Re: Exact copy of 1 line
George,
My problem is that I need to import this XML in another application (Adobe InDesign), which need those "line feeds" otherwise put all the text lines after each other. So I have to play with it in my XML. Or is there another method to catch this ?
Kind Regards,
Droom
My problem is that I need to import this XML in another application (Adobe InDesign), which need those "line feeds" otherwise put all the text lines after each other. So I have to play with it in my XML. Or is there another method to catch this ?
Kind Regards,
Droom
-
- Site Admin
- Posts: 2096
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Exact copy of 1 line
Hi Droom,
I do not understand - first you post that you get new lines as you do not want that. The cause of that is the indent set to yes that tells the XSLT processor to try to present the result in some indented form. Removing that gives exactly the output you said you want. Now you say that you need additional new lines... Maybe you can try to create a sample that shows what you have, what you need and what you got - probably it is a little more than what you shown here...
Regards,
George
I do not understand - first you post that you get new lines as you do not want that. The cause of that is the indent set to yes that tells the XSLT processor to try to present the result in some indented form. Removing that gives exactly the output you said you want. Now you say that you need additional new lines... Maybe you can try to create a sample that shows what you have, what you need and what you got - probably it is a little more than what you shown here...
Regards,
George
George Cristian Bina
-
- Posts: 9
- Joined: Fri Jan 30, 2009 6:57 pm
Re: Exact copy of 1 line
George,
If I have originaly this line:
<ElA><ElB>blabla1</ElB>blabla2<ElC>blabla3</ElC><ElA>
In some cases I like to copy nested XML elements on 1 line.
f.e. <ElA><ElB>blabla1</ElB>blabla2<ElC>blabla3</ElC><ElA>
and not as:
<ElA>
<ElB>blabla1</ElB>blabla2<ElC>blabla3</ElC>
<ElA>
Because when I import this in Adobe InDesign,
In a textframe I get:
(blanc line)
blabla1blabla2blabla3
(blanc line)
And yes, as you explained earlier, I notice that te "copy" result depends also on the type of parser (saxon versus xalan for example).
I hope this Sounds more comprehensible ?
Kind Regards,
Droom
If I have originaly this line:
<ElA><ElB>blabla1</ElB>blabla2<ElC>blabla3</ElC><ElA>
In some cases I like to copy nested XML elements on 1 line.
f.e. <ElA><ElB>blabla1</ElB>blabla2<ElC>blabla3</ElC><ElA>
and not as:
<ElA>
<ElB>blabla1</ElB>blabla2<ElC>blabla3</ElC>
<ElA>
Because when I import this in Adobe InDesign,
In a textframe I get:
(blanc line)
blabla1blabla2blabla3
(blanc line)
And yes, as you explained earlier, I notice that te "copy" result depends also on the type of parser (saxon versus xalan for example).
I hope this Sounds more comprehensible ?
Kind Regards,
Droom
-
- Site Admin
- Posts: 2096
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Exact copy of 1 line
Hi,
The solution is to not use indent="yes" on xsl:output. If you add that then you have no control on the output formatting. If you need formatting on some other part of your code you can add that in your XSLT code.
Regards,
George
The solution is to not use indent="yes" on xsl:output. If you add that then you have no control on the output formatting. If you need formatting on some other part of your code you can add that in your XSLT code.
Regards,
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service