How create markup?
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 2
- Joined: Sun Apr 04, 2021 3:22 pm
How create markup?
Hello. I have "price" field, like:
how tranform it, add markup for example +10%?
Thank you!
Code: Select all
<price>2411</price>
Code: Select all
<price>2652</price>
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How create markup?
Hi,
If you have an XML document like this:
you can create an XSLT stylesheet which adds 10% to all price elements, it would look something like this:
More about processing XML with XSLT:
https://www.oxygenxml.com/doc/versions/ ... -xslt.html
Regards,
Radu
If you have an XML document like this:
Code: Select all
<root>
<price>2411</price>
</root>
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="price">
<xsl:variable name="priceNumber" select="xs:integer(text())"/>
<xsl:value-of select="$priceNumber + ($priceNumber * 10) div 100"/>
</xsl:template>
</xsl:stylesheet>
https://www.oxygenxml.com/doc/versions/ ... -xslt.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 2
- Joined: Sun Apr 04, 2021 3:22 pm
Re: How create markup?
Thank youRadu wrote: ↑Mon Apr 05, 2021 9:28 am Hi,
If you have an XML document like this:
you can create an XSLT stylesheet which adds 10% to all price elements, it would look something like this:Code: Select all
<root> <price>2411</price> </root>
More about processing XML with XSLT:Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*"/> </xsl:copy> </xsl:template> <xsl:template match="price"> <xsl:variable name="priceNumber" select="xs:integer(text())"/> <xsl:value-of select="$priceNumber + ($priceNumber * 10) div 100"/> </xsl:template> </xsl:stylesheet>
https://www.oxygenxml.com/doc/versions/ ... -xslt.html
Regards,
Radu
I will try
Return to “General XML Questions”
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