XPath2 and format-number() - "function ... not available wi
Questions about XML that are not covered by the other forums should go here.
XPath2 and format-number() - "function ... not available wi
Hello List:
I am wanting to execute an XPath2 expression and format the numbers returned as strings with leading zeros. I expected to be able to use the function 'format-number()' but although that function is available in the oXygen XPath2 autocompleter list of functions when I execute the XPath I get an error stating that "System function format-number() is not available with this host language."
Grateful for guidance here
Thanks
Pete
I am wanting to execute an XPath2 expression and format the numbers returned as strings with leading zeros. I expected to be able to use the function 'format-number()' but although that function is available in the oXygen XPath2 autocompleter list of functions when I execute the XPath I get an error stating that "System function format-number() is not available with this host language."
Grateful for guidance here
Thanks
Pete
Re: XPath2 and format-number() - "function ... not available wi
Hello,
"format-number()" shouldn't be shown in the XPath content completion list since it's an XSLT 2.0 function and not an XPath 2.0 function. So this is a mistake on our part for listing it there in the first place.
I've added this to our issue tracking tool and we will address it in a future version of Oxygen.
The only workaround I see here to use this function is to create an XSLT 2.0 stylesheet and use this function in an <xsl:value-of select="">.
Regards,
Adrian
Edit: I forgot to mention the link to the specification:
http://www.w3.org/TR/xslt20/#function-format-number
"format-number()" shouldn't be shown in the XPath content completion list since it's an XSLT 2.0 function and not an XPath 2.0 function. So this is a mistake on our part for listing it there in the first place.
I've added this to our issue tracking tool and we will address it in a future version of Oxygen.
The only workaround I see here to use this function is to create an XSLT 2.0 stylesheet and use this function in an <xsl:value-of select="">.
Regards,
Adrian
Edit: I forgot to mention the link to the specification:
http://www.w3.org/TR/xslt20/#function-format-number
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
Re: XPath2 and format-number() - "function ... not available wi
HI Adrian
Thanks for the help.
Is it possible to use a (parameterised?) XSLT within a Schematron "assert" or "report" element? If so, can you perhaps illustrate how this is done.
Many thanks
Pete
Thanks for the help.
Is it possible to use a (parameterised?) XSLT within a Schematron "assert" or "report" element? If so, can you perhaps illustrate how this is done.
Many thanks
Pete
Re: XPath2 and format-number() - "function ... not available wi
Hi Pete,
I am afraid I do not understand exactly your question. Please provide some more details and eventually also a usecase.
In Schematron it is possible to include XSLT code, even XSLT function if you use @queryBinding="xslt2" and turn on "Allow foreign elements" from Options->Preferences -- XML / XML Parser -- ISO Schematron.
ISO Schematron also has support for abstract patterns that you can then instantiate with different parameters.
Best Regards,
George
I am afraid I do not understand exactly your question. Please provide some more details and eventually also a usecase.
In Schematron it is possible to include XSLT code, even XSLT function if you use @queryBinding="xslt2" and turn on "Allow foreign elements" from Options->Preferences -- XML / XML Parser -- ISO Schematron.
ISO Schematron also has support for abstract patterns that you can then instantiate with different parameters.
Best Regards,
George
George Cristian Bina
Re: XPath2 and format-number() - "function ... not available wi
Hi George
in a bit of XML such as
I want to set up a Schematron test to check that the doc/id values within each record are in a continuous sequence - 001, 002, 003 etc
I was hoping to use something like (for the context <record>to generate a sequence, but wanted to return the sequence padded to a pattern, in this case to a field width of 3 with leading zeroes. This was where I was thinking of using the xsl:format-number() function.
I'd appreciate list members' views.
Thanks
Pete
in a bit of XML such as
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<root>
<record id="1">
<doc>
<id>001</id>
<content>some content</content>
</doc>
<doc>
<id>002</id>
<content>some content</content>
</doc>
<doc>
<id>003</id>
<content>some content</content>
</doc>
<doc>
<id>004</id>
<content>some content</content>
</doc>
<doc>
<id>005</id>
<content>some content</content>
</doc>
</record>
<record id="2">
<doc>
<id>001</id>
<content>some content</content>
</doc>
<doc>
<id>002</id>
<content>some content</content>
</doc>
<doc>
<id>005</id>
<content>some content</content>
</doc>
</record>
</root>
I was hoping to use something like (for the context <record>
Code: Select all
for $a in ( 1 to count(doc)) return $a
I'd appreciate list members' views.
Thanks
Pete
Re: XPath2 and format-number() - "function ... not available wi
You can use a Schematron schema like:
Best Regards,
George
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<pattern id="testSequence">
<rule context="record/doc/id">
<let name="p" value="count(../preceding-sibling::doc) + 1"/>
<assert test="number(.)=$p">
The id should have the value <value-of select="$p"/>!
</assert>
<assert test="string-length(.)=3">
The id should have 3 digits (ddd), from 001 to 999.
</assert>
</rule>
</pattern>
</schema>
George
George Cristian Bina
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