How does XSLT utilize prefixed attributes from a separate so
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 9
- Joined: Thu Mar 26, 2015 5:53 am
How does XSLT utilize prefixed attributes from a separate so
I take an XML file and transform it to a fixed width utilizing XSLT, yet I'm forced to use attributes of a certain prefix. For the transformation to function properly I have to upload my finished XSLT file to a website, run it, and the website produces the necessary fixed width file.
What I want to know is how can I perform the same transformation without uploading the XSLT?
What kind of file (Schema, XSL) must I produce and link, to make sense of these attributes?
For example:
XSLT:
Notice the 'joe' prefixed attributes, what do I do to make sense of them without having to upload the XSLT and have the server do it for me? I'd prefer to do the work in a separate file versus adding variables/functions to the same note_XSL.xsl stylesheet.
I appreciate your input, thanks.
What I want to know is how can I perform the same transformation without uploading the XSLT?
What kind of file (Schema, XSL) must I produce and link, to make sense of these attributes?
For example:
Code: Select all
<!-- note_XML.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Code: Select all
<!-- note_XSL.xsl -->
<?xml version-"1.0" encoding="UTF-8"?>
<xsl:stylesheet smlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result prefixes="xs"
xmlns:joe="urn:com.website/joe" version="2.0">
<xsl:template match="/">
<Case joe:separator="
">
<Tape>
<PersonReceiving joe:fixedLength="4">
<xsl:value-of select="/note/to"/>
</PersonReceiving>
<Sender joe:fixedLength="4" joe:align="right">
<xsl:value-of select="/note/from"/>
</Sender>
etc...
</Tape>
</Case>
</xsl:template>
<xsl:stylesheet>
I appreciate your input, thanks.
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: How does XSLT utilize prefixed attributes from a separat
An xslt transformation would probably do the trick. Here's a small demonstration how to change the text content of elements with the joe:fixedLength attribute (ignoring the seperator and align attributes so far):
Test-Input:
XSL:
Output:
Regards,
Patrik
Test-Input:
Code: Select all
<Case xmlns:joe="urn:com.website/joe" joe:separator="
">
<Tape>
<PersonReceiving joe:fixedLength="4">T</PersonReceiving>
<Sender joe:fixedLength="4" joe:align="right">J</Sender>
</Tape>
</Case>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns:joe = "urn:com.website/joe"
exclude-result-prefixes="xs">
<!-- identity transformation as default templates -->
<xsl:template match="document-node() | element()">
<xsl:copy>
<xsl:apply-templates select="attribute() | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text() | attribute() | processing-instruction() | comment()">
<xsl:copy/>
</xsl:template>
<!-- handling elements with joe:fixedlength attribute -->
<xsl:template match="*[@joe:fixedLength]">
<xsl:copy>
<!-- don't copy any sub-items except the text -->
<xsl:value-of select="for $i in (1 to (xs:integer(@joe:fixedLength) - string-length(text()))) return ' '" separator=""/>
<xsl:copy-of select="text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<Case xmlns:joe="urn:com.website/joe" joe:separator="
">
<Tape>
<PersonReceiving> T</PersonReceiving>
<Sender> J</Sender>
</Tape>
</Case
Patrik
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: How does XSLT utilize prefixed attributes from a separat
Of course you could adapt the existing stylesheet as well by droping the joe-attibutes and directly formatting the values. But I understood that you WANT to use another transformation...
-
- Posts: 9
- Joined: Thu Mar 26, 2015 5:53 am
Re: How does XSLT utilize prefixed attributes from a separat
Patrik,
I believe its missing something, I can't get the fixedLength attribute to work; should I have declared the attribute somehow? I'm sorry, I'm quite new to XSL/XML.
And how do we link-up the stylesheets? I went to "Configure Transformation Scenario" and selected "Additional XSLT stylesheets"; is that how its done?
thanks again.
I believe its missing something, I can't get the fixedLength attribute to work; should I have declared the attribute somehow? I'm sorry, I'm quite new to XSL/XML.
And how do we link-up the stylesheets? I went to "Configure Transformation Scenario" and selected "Additional XSLT stylesheets"; is that how its done?
thanks again.
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: How does XSLT utilize prefixed attributes from a separat
Sorry, but I can't help you since I don't understand what you actually want and my assumptions appear to be wrong.
Regards,
Patrik
Regards,
Patrik
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