Add pipe character and eliminate white space
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 12
- Joined: Fri Mar 02, 2012 12:11 am
Add pipe character and eliminate white space
Two questions.
How to get "pipe" inbetween value?
How to get rid of whitespace > 1 space?
How to get "pipe" inbetween value?
How to get rid of whitespace > 1 space?
Code: Select all
<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.8" productVersion="12.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\mbj3f\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer2\c26babb28b984f84\manifest.xsf" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?>
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-03-12T14:44:04"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
<my:Metric_ID>176</my:Metric_ID>
<my:BestPracticeGroup>
<my:BestPracticeSection>
<my:BestPractice>"Alarms-Utilize movement alarms:Bed alarms Chair
alarms"</my:BestPractice>
<my:ActionGroup>
<my:ActionTable>
<my:Action>one, one</my:Action>
<my:ActionDate>2012-03-13</my:ActionDate>
<my:ActionStatus>None</my:ActionStatus>
<my:HiddenField>176|one, one|"Alarms-Utilize movement alarms:Bed alarms Chair
alarms"|2012-03-13|None</my:HiddenField>
</my:ActionTable>
<my:ActionTable>
<my:Action>one, two</my:Action>
<my:ActionDate xsi:nil="true"/>
<my:ActionStatus>Some</my:ActionStatus>
<my:HiddenField>176|one, two|"Alarms-Utilize movement alarms:Bed alarms Chair
alarms"||Some</my:HiddenField>
</my:ActionTable>
</my:ActionGroup>
</my:BestPracticeSection>
<my:BestPracticeSection>
<my:BestPractice>"Complete central line insertion checklist in real
time"</my:BestPractice>
<my:ActionGroup>
<my:ActionTable>
<my:Action>two, one</my:Action>
<my:ActionDate xsi:nil="true"/>
<my:ActionStatus/>
<my:HiddenField>176|two, one|"Complete central line insertion checklist in real
time"||</my:HiddenField>
</my:ActionTable>
<my:ActionTable>
<my:Action>two, two</my:Action>
<my:ActionDate>2012-03-15</my:ActionDate>
<my:ActionStatus>Test</my:ActionStatus>
<my:HiddenField>176|two, two|"Complete central line insertion checklist in real
time"|2012-03-15|Test</my:HiddenField>
</my:ActionTable>
</my:ActionGroup>
</my:BestPracticeSection>
</my:BestPracticeGroup>
</my:myFields>
Code: Select all
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-03-12T14:44:04">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:param name="lf" select="' '"/>
<xsl:template match="my:HiddenField">
<xsl:for-each select="descendant::*">
<xsl:text>/</xsl:text>
<xsl:for-each select="ancestor-or-self::*">
<xsl:value-of select="local-name()"/>
<xsl:if test="position() != last()">
<xsl:text>/</xsl:text>
<!-- <xsl:value-of select="'|'"/> --> Insert pipe btw fields? Strip-out spaces > 1
</xsl:if>
</xsl:for-each>
<xsl:value-of select="$lf"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
-
- Posts: 12
- Joined: Fri Mar 02, 2012 12:11 am
Re: Add pipe character and eliminate white space
Found the whitespace solution, added below to xsl. Still not sure why pipe character is not appending?
<xsl:template match="text()">
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Add pipe character and eliminate white space
Hi,
That character is not appending because the stylesheet never gets to that point. You have an <xsl:for-each select="descendant::*">, but my:HiddenField has no descendants, so the XSLT execution never enters that for-each block.
Use the XSLT debugger from Oxygen to see how the XSLT is executed.
Regards,
Adrian
That character is not appending because the stylesheet never gets to that point. You have an <xsl:for-each select="descendant::*">, but my:HiddenField has no descendants, so the XSLT execution never enters that for-each block.
Use the XSLT debugger from Oxygen to see how the XSLT is executed.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ 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