Conditional Character map?
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 269
- Joined: Sat Jul 10, 2010 4:03 pm
Conditional Character map?
I need to generate output for different media targets from the same xml source.
One of the targets is mobi pocket for the Kindle, with 1980's era markup capability. I have 10-15 unicode characters in the xml, like en-dashes, em-dashes, thin spaces, etc. that the kindle doesn't have support for in it's font set.
I would like to be able to conditionally use a character map in the same xsl script, that would leave the characters alone for html or epub, but replace them if generating for the Kindle.
Is this possible?
thanks,
Scott
One of the targets is mobi pocket for the Kindle, with 1980's era markup capability. I have 10-15 unicode characters in the xml, like en-dashes, em-dashes, thin spaces, etc. that the kindle doesn't have support for in it's font set.
I would like to be able to conditionally use a character map in the same xsl script, that would leave the characters alone for html or epub, but replace them if generating for the Kindle.
Is this possible?
thanks,
Scott
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Conditional Character map?
Hello,
xsl:character-map allows a "use-when" attribute(Conditional Element Inclusion) but unfortunately its value is evaluated statically so you can't use a parameter or variable to trigger it.
Regards,
Adrian
xsl:character-map allows a "use-when" attribute(Conditional Element Inclusion) but unfortunately its value is evaluated statically so you can't use a parameter or variable to trigger it.
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
-
- Posts: 269
- Joined: Sat Jul 10, 2010 4:03 pm
Replace unicode with html entitys; was
Instead of using character-map I am trying to use the translate function.
Using this works well
translate(.,"-,'-')
but this fails
translate(.,'®,'®')
with
F [Saxon-HE 9.3.0.4] The entity "reg" was not declared, but was referenced in the attribute "select" of the element "xsl:value-of".
How can I get the translate function to output ® if it sees ®?
Scott
Using this works well
translate(.,"-,'-')
but this fails
translate(.,'®,'®')
with
F [Saxon-HE 9.3.0.4] The entity "reg" was not declared, but was referenced in the attribute "select" of the element "xsl:value-of".
How can I get the translate function to output ® if it sees ®?
Scott
-
- Posts: 269
- Joined: Sat Jul 10, 2010 4:03 pm
Re: Conditional Character map?
Hmmm...
Using translate() is going so well..
I tried declaring this
<!DOCTYPE stylesheet [
<!ENTITY reg
"<xsl:text disable-output-escaping='yes'> '®' </xsl:text>">
]>
To allow me to use the ® entity, but that causes another error at the point of the ® ..
F [Saxon-HE 9.3.0.4] The value of attribute "select" associated with an element type "xsl:value-of" must not contain the '<' character.
?????
Using translate() is going so well..
I tried declaring this
<!DOCTYPE stylesheet [
<!ENTITY reg
"<xsl:text disable-output-escaping='yes'> '®' </xsl:text>">
]>
To allow me to use the ® entity, but that causes another error at the point of the ® ..
F [Saxon-HE 9.3.0.4] The value of attribute "select" associated with an element type "xsl:value-of" must not contain the '<' character.
?????
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Conditional Character map?
Hello,
If you want to use the translate function you need a 1 to 1 mapping of the characters in the second and third argument strings(1 character in the second argument is replaced with the corresponding character from the third argument). But if I understand correctly you want to replace a character with an entity(1 to many): ® -> ® so you're going to have to use the replace function instead.
e.g.
PS: If you declare an entity and use an XML/XSL snippet as its value, when the stylesheet is compiled the parser will substitute the entity reference with its value so you will obtain an invalid stylesheet(an xml:text element inside the value of the select attribute. Hence the error...
Regards,
Adrian
If you want to use the translate function you need a 1 to 1 mapping of the characters in the second and third argument strings(1 character in the second argument is replaced with the corresponding character from the third argument). But if I understand correctly you want to replace a character with an entity(1 to many): ® -> ® so you're going to have to use the replace function instead.
e.g.
Code: Select all
<xsl:value-of select="replace(.,'®','®')" disable-output-escaping="yes"/>
PS: If you declare an entity and use an XML/XSL snippet as its value, when the stylesheet is compiled the parser will substitute the entity reference with its value so you will obtain an invalid stylesheet(an xml:text element inside the value of the select attribute. Hence the error...
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
-
- Posts: 269
- Joined: Sat Jul 10, 2010 4:03 pm
Re: Conditional Character map?
I bailed on the utility of having it in a single stylesheet and went with a kludge of having my character-maps in separate style sheets.
Not a neat and tidy as I'm used to when coding in a real programming language but it does work.
thanks for all the input.
Scott
Not a neat and tidy as I'm used to when coding in a real programming language but it does work.
thanks for all the input.
Scott
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