Link to home
Start Free TrialLog in
Avatar of charthumser

asked on

When using XSL to transform XML for InDesign, How do I get the bold to output

Thank you in advance for any help you can provide.

I have an XML document provided to me,  here's a snippet:

<?xml version="1.0" standalone="no"?>
<?whitespace-handling use-characters?>
<pub-code>UNG VP
<ad-type>CLS 6 Col Tab
<account-name>OREGON WCP STATEWIDE CLASS</account-name>
<addr-1>133 ENTERPRISE DRIVE </addr-1>
<addr-2> </addr-2>
<b>ATTENTION DIABETICS </b>with Medicare.  Get a FREE Talking Meter and diabetic supplies at NO COST plus FREE home delivery!  Best of all, this meter eliminates painful finger pricking!  Call 1-888-667-5202 (wcan)</ad-content>

I need to pull the data out of it that I need (not all) and apply formatting. I also don't want any repeating heads. I have accomplished this much with XSL.

What I can't get is the bold tag, within the ad-content tag to show up in the output.

Here is the XSL:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"

<xsl:template match="/">
<!--Container Element -->
<xsl:element name="ad-type">
<!--Start loooping through XML data -->
 <xsl:for-each select="web-export/run-date/pub-code/ad-type">
<!--Set up elements. Do not ouput subclass-code and position-description dups-->
                  <xsl:value-of select='concat(subclass-code[not(.=preceding::subclass-code)], " ", position-description[not(.=preceding::position-description)])'/>
<!--Carriage Return -->
<!--Add ad content -->
      <ad-content><xsl:value-of select="ad-content"/>

<!--Carriage Return -->    

Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

short answer:
replace this
<ad-content><xsl:value-of select="ad-content"/>
by this
<xsl:copy-of select="ad-content"/>

value of will only show the text nodes
copy-of will make a deep copy
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of charthumser


Wow. you've got to be kidding?!

Will that take care of italics and underlines too?

Actually, it's a bit doesn't always end the bold.
it takes care of all the deeper nodes, italics and underline too

do you mean that your source is not well formed?
what is flakey?
I meant that it wasn't always ending the bold where it was supposed to, it would bold the whole paragraph instead of just the word(s) between the tags.

Your revised code worked perfectly. I posted the flaky comment before I seen your code.

One more question, I have a carriage return after the subclass-code because without it, the Paragraph marker was applying the style from the next element. Any ideas?

I really appreciate the help, I was pulling my hair out on this one.

OH, I see,
I have no clue about the paragraph marker
depends on how you look at the result